-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
setTimeout per test? #5055
Comments
You can use the third argument to test('example', async () => {
await new Promise(resolve => setTimeout(resolve, 1000));
}, 500); |
ah interesting, is this not in the documentation? |
Looks like it isn't 😅. Would you like to contribute that change to docs? |
@thymikee actually, I just ran your example and it didn't work, eg: // stuff.test.js
describe('Test', () => {
test('timeout', async () => {
await new Promise(resolve => setTimeout(resolve, 1000));
}, 500);
});
|
It ended after ~500ms, which is shorter that 1000ms your async callback takes, therefore it fails as expected. |
Closing this. Happy to accept a PR with docs change though :) |
ah you're right, I don't know what I was thinking hehe... I'll update the docs! Thanks! |
i got an same error "Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout." describe('POST /.......',()=>{
}); Somebody have a solution ,pls send me |
pass done into the test and call it after the assertion
|
no need to use |
This comment has been minimized.
This comment has been minimized.
So a StackOverflow answer says you cannot set a timeout in the test function that is greater than the default timeout - I cannot find documentation on this but my own test show that the timeout I put in the test fn will be ignored.
If I add:
Then it works fine. I am on 24.8.0. Thoughts? Where can I find this in docs and if it's true as it appears then why? What is the point of not being able to set a timer greater than default? |
jest.setTimeout(60000)
test('Sys Test No Control', async function() {
... This worked for me. Cleaner than a hackey undocumented 3rd. parameter to a function. CLI instructions ineed to be updated... they say to change |
I believe it('does a lot of stuff exceeding default 5 sec timeout', async () => {
...
}, 10000) |
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. |
Sorry if this is obvious, but I couldn't find how to do this on the website. Basically, I want to set a different default timeout for each test, eg:
Do I just call
jest.setTimeout(time);
inside eachtest
like this:? Or is there a better way? Would be nice if you could do something like:
The text was updated successfully, but these errors were encountered: