Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make jasmine.DEFAULT_TIMEOUT_INTERVAL configurable #652

Closed
tonekk opened this issue Dec 16, 2015 · 25 comments
Closed

Make jasmine.DEFAULT_TIMEOUT_INTERVAL configurable #652

tonekk opened this issue Dec 16, 2015 · 25 comments

Comments

@tonekk
Copy link

tonekk commented Dec 16, 2015

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 to jestConfig.defaultTimeoutInterval || 5000
@tobowers
Copy link

👍

@cpojer
Copy link
Member

cpojer commented Feb 18, 2016

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.

@cpojer cpojer closed this as completed Feb 18, 2016
@hakunin
Copy link

hakunin commented Aug 8, 2016

if you need it in every test you can set it in the setup-env file.

@cpojer Where / how?

@cpojer
Copy link
Member

cpojer commented Aug 9, 2016

Sorry, I mean the setupFiles config option: http://facebook.github.io/jest/docs/api.html#setupfiles-array

@hakunin
Copy link

hakunin commented Aug 10, 2016

Thanks for the clarification. I my setupfile, I tried setting jasmine.DEFAULT_TIMEOUT_INTERVAL but it says Jasmine isn't there. I ended up putting the line in the test itself.

I can only access jasmine from "setupTestFrameworkScriptFile".

@cpojer
Copy link
Member

cpojer commented Aug 10, 2016

Phew, I'm sorry again. setupFiles actually runs before we set-up jasmine. We have setupTestFrameworkScriptFile which runs after jasmine and before your test.

@itsovereasy
Copy link

These docs apparently don't exist anymore. How can I configure that timeout interval in the current version?

@cpojer
Copy link
Member

cpojer commented Oct 6, 2016

Somebody should send a PR for jest.setTestTimeout(time) so we have an official forward-looking API for this.

@louisremi
Copy link

May I suggest improving the API reference and troubleshooting section in the docs to indicate that Jasmine's it has an optional timeout third argument?
(willing to do that PR if you want)

@jzaefferer
Copy link

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 as setupTestFrameworkScriptFile resulted in Cannot find module 'jasmine' from 'testSetup.js'

to indicate that Jasmine's it has an optional timeout third argument?

I tried that, too, but it didn't make any difference.

@phil-r
Copy link

phil-r commented Apr 7, 2017

@jzaefferer Add it to the test file itself

@sudhanshuraheja
Copy link

5000 works well as a global config, if you want to change the timeout for a specific test, please do this

test("test an API which takes time", () => {

    doYourThing()

}, 10000)

@phil-r
Copy link

phil-r commented Apr 10, 2017

@sudhanshuraheja thanks, that works ;) although I found a way to avoid doing that altogether

@warent
Copy link

warent commented Apr 27, 2017

@phil-r care to share with the rest of the class? 😄

@phil-r
Copy link

phil-r commented Apr 28, 2017

@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.

@benjick
Copy link

benjick commented Sep 6, 2017

So what's the correct way of setting timeouts globally? The URLs in this issue are obsolete

@jordaaash
Copy link

@benjick Per https://facebook.github.io/jest/docs/en/troubleshooting.html#unresolved-promises

jest.setTimeout(10000); // 10 second timeout

I do this in a setup file (https://facebook.github.io/jest/docs/en/configuration.html#setupfiles-array)

@emilgoldsmith
Copy link
Contributor

Thanks for that @jordansexton, just a note though, it doesn't seem to work if using the setupFiles config, only with the setupTestFrameworkScriptFile 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-string

@Nilegfx
Copy link

Nilegfx commented Mar 19, 2018

future references, this worked for me

@emilgoldsmith
Copy link
Contributor

Yep that's what I did as well

@rjurney
Copy link

rjurney commented Mar 23, 2018

@sudhanshuraheja Thanks for the tip!

@kyriediculous

This comment has been minimized.

@kirillgroshkov
Copy link

jest.setTimeout(10000) in setupTestFrameworkScriptFile works

@do0g
Copy link

do0g commented Jul 19, 2019

setupTestFrameworkScriptFile is now deprecated, so the way to get this working is to add

  "setupFilesAfterEnv": [
    "<rootDir>/src/__test__/setup.js"
  ]

to the jest property of your package.json or jest.config.* file, and add jest.setTimeout(n) to src/__test__/setup.js.

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests