-
-
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
Exceeded timeout of 5000 ms for a test #11607
Comments
I've created a repro for my case: https://github.com/cBiscuitSurprise/jest-setTimeout-11607-repro |
I have the same error on my repo: playwright-fluent. beforeEach((): void => {
jest.setTimeout(60000);
p = new SUT.PlaywrightFluent();
}); When upgrading to v27.0.5, every test now fails with the error message: thrown: "Exceeded timeout of 5000 ms for a test.
Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test." To reproduce the problem:
Thanks |
@psxpa3 @hdorgeval Are you guys on Windows 10 + WSL2 (Ubuntu)? I started to see these on that system, a while back, but not on macOS or Alpine Linux. —- Edit: Got my timeout problems resolved. Were likely unrelated to things reported here. |
@akauppi I have the same problem since we updated to Jest 27. I am on Windows 10 + WSL1 (Ubuntu), if that helps anyone. |
Hi @akauppi , I have the problem on my Mac (Big Sur 11.4), but also when running the tests on Github CI/linux and on Appveyor. So I have the same problem on all platforms. It seems to me that this problem only happens to those who are using jest with an e2e testing framework, because in this situation tests are likely to run in more than 5 seconds. In my case, tests run on an average of 30s, but it can take up to several minutes. |
Same problem, some solution is to add: |
Hi @vdanchenkov, unfortunately your workaround did not work in my case. |
Same problem on linux. |
I ran @cBiscuitSurprise's repro and was able to reproduce the issue with jest v27 Looks like
Did not work for me |
Reading the changes to v27 here: https://jestjs.io/blog/2021/05/25/jest-27
then for the other
The 10000 in the Looks like we have a workaround for now? |
Hi @phil-lgr , I tried your work-around on my repo Unfortunately it does not work for me. The main difference with your code is that all my tests have a beforeEach/afterEach and for some a BeforeAll/AfterAll. |
Same as @hdorgeval on my end. |
// jest.config.js
module.exports = {
// ...
testTimeout: 20000
} It seems to solve the problem. |
Have you tested this? We tried it and it didn't work. |
@JonWallsten I have tested that. Setting |
Same for my react native project. |
Hi @izhaoqing , thank you for your feedback! 👍 // jest.config.js
module.exports = {
// ...
testTimeout: 20000
} This solved the problem for me, and unlike others in this issue, this is the only working solution for my use case (playwright-fluent). |
It works like a champ |
In my React Native project I had an issue where Jest was failing on
With the error: So I added this after my imports in the Test file:
Then I added this to each test case:
Now it's working again. Heres an example:
|
This one worked for me. Thanks! |
This solved the issue for me. What that option does? Is v27 broken? |
I had the 5000 ms timeout error in one of my tests, and it kept occurring even after setting EDIT Interestingly, on Linux, it seems to be the opposite: |
Used @wbsdickson suggestions and it worked for me. Thank you so much. |
Unfortunately, I have tried the solutions mentioned above but my tests keep timing out, even tho I have been able to log both in the terminal console within afterEach callback and on the browser, both of them are being populated correctly. Despite increasing the timeout to 30 or 60s it will always timeout. My test environment uses JSDom, my API is promise based and I use Fetch API which I am mocking using: global.fetch = jest.fn()
.mockImplementation(() => {
return Promise.resolve({json: () => mockData})
}) Where mockData is a JSON file. My dependencies are the following: {
"jest": "^27.2.5",
"ts-jest": "^27.0.5",
"typescript": "^4.4.3"
} My node and npm versions:
My operating system:
|
This did work for me. |
same for me, my solution was put write |
Your solution worked for me, thank you |
I'm not 100% sure but I faced this error after run |
I can confirm that for my case, Thank you very much guys |
adding jest.setTimeout(30000); before the describe block worked for me.
|
this is the only one that worked for me "devDependencies": {
"babel-jest": "^27.3.1",
"jest": "^27.3.1"
}, |
Same issue, |
I can't comment right now about the Win 10 stuff, but for me, using testTimeout in my package.json file got me past this bizarre issue. I'm trying to run an async Selenium test inside Jest. Not sure if this SO post is related or not... |
This worked for me. I'm running jest |
For me the problem is solved when I use the flag --runInBand. With the command |
As noted in the Bug Report template, all bug reports requires a minimal reproduction. Please open up a new issue providing one. Read more at https://stackoverflow.com/help/minimal-reproducible-example. |
@SimenB did you not see this (first comment posted in June of 2021)? #11607 (comment) |
I need the timeout inside a test. And I am using create-react-app with Craco. Any solutions for this? |
To get my test back to working after upgrading I did two things
|
Actually i am having the same problem and i tried everything it not work someone knows an other solution ? i dont use any timer the bug is when i try to test my login route |
This comment works for me, with |
I have solved most of my problems by increasing timeout or using faketimers. But i am getting error on this one which i am unable to resolve, any help would be appreciated. thrown: "Exceeded timeout of 20000 ms for a hook.
|
I was extracting "done" as argument from my callback function: it('throws an error if the email is already in use', async (done) => {
expect.assertions(1);
fakeUsersService.find = () => Promise.resolve([{ email: '[email protected]' } as User]);
await expect(service.signup('[email protected]', '123456')).rejects.toThrow(BadRequestException);
}); Removing the |
@AsadShah1995 have you tried with This comment? It works for me, with |
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. |
I am upgrading jest from v1.4.3 --> 2+, with chromedriver version 91+. I have started getting this issue:
thrown: "Exceeded timeout of 5000 ms for a test. Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."
I have been googling a lot but not getting proper solution. So, far I have tried following solutions:-
1)Increased jest.setTimeout(30000) from 30000 to 60000.
2)Tried using jest- testRunner": "jest-circus/runner"
My package.json configuration is as below:
"@types/jest": "26.0.23",
"@types/node": "15.12.4",
"@types/selenium-webdriver": "4.0.14",
"chromedriver": "91.0.1",
"concurrently": "6.2.0",
"jest": "27.0.5",
"prettier": "2.3.1",
"selenium-webdriver": "4.0.0-alpha.7",
"ts-jest": "27.0.3",
"tslint": "6.1.3",
"tslint-config-prettier": "^1.15.0",
"tslint-config-sparta": "0.3.4",
"tslint-loader": "3.5.4",
"typedoc": "0.21.0",
"typescript": "3.9.7",
"ui-testing-core": "0.15.12"
Can anybody point out what is the solution?
The text was updated successfully, but these errors were encountered: