jest: Make jasmine.DEFAULT_TIMEOUT_INTERVAL configurable
5 seconds can be really annoying if you have many test cases that fail.
I’m not sure what would be the best option to accomplish this, but I imagine a configurable option in package.json
. Something like defaultTimeoutInterval
, which would then be passed to jasmine used.
Steps:
- Pass jest json config to jasmine file (not sure how)
- Change
jasmine.DEFAULT_TIMEOUT_INTERVAL
tojestConfig.defaultTimeoutInterval || 5000
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 8
- Comments: 25 (6 by maintainers)
5000 works well as a global config, if you want to change the timeout for a specific test, please do this
I think it is enough to set this on a per-test level. This already works. If you need it in every test you can set it in the setup-env file.
While this issue is closed, I just ran into it as well, and couldn’t figure out a solution. Nothing in here nor in #896 helped.
Specifically, adding
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
to the file configured assetupTestFrameworkScriptFile
resulted inCannot find module 'jasmine' from 'testSetup.js'
I tried that, too, but it didn’t make any difference.
npm uninstall jest --save
Best solution
Or delete the timeout code in que_runner.js
Making config and setup doesn’t work
@benjick Per https://facebook.github.io/jest/docs/en/troubleshooting.html#unresolved-promises
I do this in a setup file (https://facebook.github.io/jest/docs/en/configuration.html#setupfiles-array)
Sorry, I mean the
setupFiles
config option: http://facebook.github.io/jest/docs/api.html#setupfiles-arrayThanks for that @jordansexton, just a note though, it doesn’t seem to work if using the
setupFiles
config, only with thesetupTestFrameworkScriptFile
which runs after the test framework has been installed, so the correct documentation URL is: https://facebook.github.io/jest/docs/en/configuration.html#setuptestframeworkscriptfile-stringSomebody should send a PR for
jest.setTestTimeout(time)
so we have an official forward-looking API for this.May I suggest improving the API reference and troubleshooting section in the docs to indicate that Jasmine’s
it
has an optionaltimeout
third argument? (willing to do that PR if you want)setupTestFrameworkScriptFile
is now deprecated, so the way to get this working is to addto the
jest
property of yourpackage.json
orjest.config.*
file, and addjest.setTimeout(n)
tosrc/__test__/setup.js
.@sudhanshuraheja Thanks for the tip!
@warent I don’t remember exactly what the issue was, but I wasn’t using fake timers correctly. After I fixed the issue with fake timers in my test, there was no need for increased timeout.
@phil-r care to share with the rest of the class? 😄
Phew, I’m sorry again.
setupFiles
actually runs before we set-up jasmine. We havesetupTestFrameworkScriptFile
which runs after jasmine and before your test.