Synchronous tests don't time out
See original GitHub issue🐛 Bug Report
jest.setTimeout(timeout)
does not time out for synchronous tests.
To Reproduce
run
it('times out', () => {
const startTime = new Date().getTime();
while (new Date().getTime() - startTime < 10000) {
// wait
}
});
Expected behavior
The test times out.
Link to repl or repo
https://repl.it/@gitlab_winnie/jestsetTimeouttimeout-for-synchronous-tests
Run npx envinfo --preset jest
Binaries:
Node: 9.0.0 - ~/.nvm/versions/node/v9.0.0/bin/node
Yarn: 1.7.0 - /usr/local/bin/yarn
npm: 5.8.0 - ~/.nvm/versions/node/v9.0.0/bin/npm
npmPackages:
jest: ^23.5.0 => 23.5.0
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:21 (5 by maintainers)
Top Results From Across the Web
Dealing With Synchronization Issues in Tests | Detox
We are waiting too much - The test will appear to hang and fail with timeout. This happens because Detox thinks an asynchronous...
Read more >Stopping tests on timeout - TestArchitect Docs
A test case timeout occurs during runtime when run duration, accumulated from the beginning of a test case, exceeds a specific timeout. Run...
Read more >Message "Async callback was not invoked within the 5000 ms ...
Sometimes, when I run the tests, everything works as expectedly. Other times, I get an error: Timeout - Async callback was not invoked...
Read more >How Does Silk Test Workbench Synchronize Tests?
If Silk Test Workbench cannot immediately find an object, Silk Test Workbench will retry to find the object until the object resolve timeout...
Read more >Handle pauses & timeouts effectively - BDD framework for NET
Stan Desyatnikov proposed a way to rephrase the waiting scenarios. “Don't reflect delays (of the application under testing) in steps of scenarios… Wait...
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
@rubennorte Maybe we can create a separate follow-up issue to discuss whether this should become the default behavior? Then people can throw their 👍s and 👎s at it after trying it out. 😃
Personally I wouldn’t mind if it is not the default but having it at all would be a big help.
I am able repro this. I also was able to narrow it down (in my case) to nested long running
for
loops: