setTimeout is not promisifiable
See original GitHub issueThe simple testcase
const {promisify} = require('util');
const timeout = promisify(setTimeout);
test('should timeout', async () => {
await timeout(100);
});
works in Node environment, but fails in JSDOM. The difference is that JSDOM gives custom setTimeout implementation, that doesn’t work with Node built-in util.promisify
.
Is there a way to make this work? For example, get the original Node’s setTimeout
within JSDOM.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
setTimeout() - Web APIs - MDN Web Docs
setTimeout () is an asynchronous function, meaning that the timer function will not pause execution of other functions in the functions stack. In ......
Read more >setTimeout or setInterval? - javascript - Stack Overflow
setTimeout () is a time based code execution method that will execute a script only one time when the interval is reached. It...
Read more >When should one use setTimeout and what are the ... - Quora
You should never use timeout instead of a promise, they do not serve the same purpose. Promise allows you to associate handlers with...
Read more >Why setTimeout Does Not Guarantee Time to Execution
I want to go deeper into the asynchronicity of Javascript through a setTimeout example and why it is not a guarantee of time...
Read more >Datatable not working when I am using settimeout function?
Features like search, sort, pagination, mobile responsive not working. I'm using bootstrap 3, jquery datatable version - 1.10.10.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If this is not a bug, then it should show a different error message. Currently it just fails due to test duration timeout.
Maybe if people will find this issue, it already would give them a pointer where to look.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.