Unit Testing Functionality: Testing setTimeout and setIntervalby@bob.js
6,032 reads
6,032 reads

Unit Testing Functionality: Testing setTimeout and setInterval

by Bob Fornal4mOctober 17th, 2020
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Pattern is a patch using a pattern I am somewhat uncomfortable with as a tester, but given the amount of code already in place, this seemed like a reasonable option. The pattern discussed would allow for both sets of functionality to be wrapped in such a way that they can be removed, as needed. This functionality allowed the IDs to be stored in a way they could be removed as the tests iterated. With this code, we can simply test the function inside the setTimeout function. The timer behavior could be mocked.

Company Mentioned

Mention Thumbnail
featured image - Unit Testing Functionality: Testing setTimeout and setInterval
Bob Fornal HackerNoon profile picture
Bob Fornal

Bob Fornal

@bob.js

REAL, FUN, GEEK who is passionate about Front-End!

About @bob.js
LEARN MORE ABOUT @BOB.JS'S
EXPERTISE AND PLACE ON THE INTERNET.

Share Your Thoughts

About Author

Bob Fornal HackerNoon profile picture
Bob Fornal@bob.js
REAL, FUN, GEEK who is passionate about Front-End!

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite
Also published here
L O A D I N G
. . . comments & more!