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

Jest: passing jasmine Timeout in all tests #5247

Closed
nkulkarni8 opened this issue Jan 8, 2018 · 14 comments
Closed

Jest: passing jasmine Timeout in all tests #5247

nkulkarni8 opened this issue Jan 8, 2018 · 14 comments

Comments

@nkulkarni8
Copy link

I am executing jest test. I don't want to specify jasmine.DefaultTimeoutInterval in all my test..

Is there any way where I can just specify once instead of giving in all my tests?

@thymikee
Copy link
Collaborator

thymikee commented Jan 8, 2018

@thymikee thymikee closed this as completed Jan 8, 2018
@nkulkarni8
Copy link
Author

Thanks for the response. I tried created a setup file.js
And just mentioned :
var jasmine = require ('jasmine');
jasmine.DefaultTimeoutInterval = 20000;

And then I tried to call this file I'm setuptestframework

But somehow it stilll gave me a error for Async callback

Let me know if I am missing something here..

@thymikee
Copy link
Collaborator

thymikee commented Jan 8, 2018

Don't require jasmine, use jest.setTimeout(x) or jasmine.DEFAULT_TIMEOUT_INTERVAL = x.
See how we do it here: https://github.com/facebook/jest/blob/master/test_setup_file.js

@SimenB
Copy link
Member

SimenB commented Jan 8, 2018

(Please use jest.setTimeout(x), jasmine global should really not be used)

@frangeris
Copy link

frangeris commented Mar 2, 2018

Future references, testSetupFile.js:

// jest.config.js
module.exports = {
  setupTestFrameworkScriptFile: './jest.setup.js'
}

// jest.setup.js
jest.setTimeout(10000)

@kyriediculous
Copy link

kyriediculous commented Jun 22, 2018

Doesn't work, url is dead

@aldeed
Copy link

aldeed commented Jun 25, 2018

@rjhilgefort
Copy link

I'm doing what @frangeris suggested and I'm not seeing my tests timeout increased- they're still timing out like they were before. Am I missing something? Is that still the best way to globally update timeouts?

@Kocal
Copy link

Kocal commented May 20, 2019

I can confirm this does not work (anymore?), with Jest v24.7.1.

I'm using this configuration:

// jest.config.js
module.exports = {
  setupFiles: [
    '<rootDir>/test/setup.js'
  ]
};
// test/setup.js
console.log('set timeout');
jest.setTimeout(...);

Note that set timeout is properly logged before every tests. So... maybe jest.setTimeout() does not work? 🤔

Thanks!

@Kocal
Copy link

Kocal commented May 22, 2019

Hum, after some investigations I found this while looking at the definition of jest.setTimeout():

  • Using console.log(this._environment.global.jasmine) display undefined, so this._environment.global.jasmine._DEFAULT_TIMEOUT_INTERVAL is never called
  • so it fallback to this._environment.global[testTimeoutSymbol] = timeout but I don't see where it is used in Jest packages

@skratchdot
Copy link
Contributor

@Kocal -
If you use setupFilesAfterEnv instead of setupFiles to call your jest.setTimeout() code, it should work. I've confirmed in my suite that calling jest.setTimeout() in setupFiles does not work, but setupFilesAfterEnv works (at least for my use case which is using jest 24.9.0).

@Kocal
Copy link

Kocal commented Sep 11, 2019

Oh, okay. I was planning to use #8456 but I will give setupFilesAfterEnv a try.

Thanks :)

Kocal added a commit to Yproximite/yProx-CLI that referenced this issue Sep 19, 2019
@Kocal
Copy link

Kocal commented Sep 19, 2019

setupFilesAfterEnv is working properly, thanks @skratchdot :)

Kocal added a commit to Yproximite/yProx-CLI that referenced this issue Sep 19, 2019
* use path.join()

* lighten env tests

* test: set default timeout to 35000 ms

* chore: use "setupFilesAfterEnv" instead of "setupFiles"

jestjs/jest#5247 (comment)

* fix(test): timeout vue 50000

* fix failing tests

* fix ansi
@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

9 participants