paint-brush
Unit Testing Functionality: Testing setTimeout and setIntervalby@bob.js
6,053 reads
6,053 reads

Unit Testing Functionality: Testing setTimeout and setInterval

by Bob FornalOctober 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.
featured image - Unit Testing Functionality: Testing setTimeout and setInterval
Bob Fornal HackerNoon profile picture
Bob Fornal

Bob Fornal

@bob.js

L O A D I N G
. . . comments & more!

About Author

Bob Fornal HackerNoon profile picture
Bob Fornal@bob.js

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