-
-
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
jest.setTimeout()
is ignored if run async'ly in beforeAll()
hook
#9359
Comments
jest.setTimeout()
is ignored if run async'ly in beforeAll()
hook
If u specify timeout as second parameter in beforeAll(async () => {
// hook logic
}, 10000); |
@lamanabie thanks. That only affects the timeout of the before-all clause itself, rather than applying the timeout over that and any future clauses (e.g. |
Dealing with this issue jestjs/jest#9359
I see this is an old ticket, but I am still facing the same issue, I tried the proposed solution but I still get this error:
That said, even though adding the timeout as the second argument of the it("should do something", async () => {
// ...
}, 10000) |
* docs: find functions to which the deprecated `fields` option is passed * fix: trying the use of `project` on models/user.js::fetchMulti() cf https://stackoverflow.com/a/51732851/592254 * fix(tests): Exceeded timeout of 5000 ms for a hook cf https://github.com/openwhyd/openwhyd/actions/runs/5646589314/job/15294832053?pr=628#step:5:47 * fix: use `project` on models/post.js::fetchPosts() * fix: use `project` on models/mongodb.js::forEach() * fix: use `project` on models/mongodb.js::forEach2() * fix `Exceeded timeout of 5000 ms for a hook` cf jestjs/jest#9359 (comment) * fix: use `project` on models/follow.js::fetchArray() * fix: remove TODOs fixed by previous commit * fix: use `project` on models/comment.js::fetch() * fix: use `project` on controllers/admin/index.js::countDbUsersAndPlaylists() * fix: use `project` on controllers/admin/index.js::refreshIndex()
This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days. |
This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one. |
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. |
🐛 Bug Report
jest.setTimeout()
works if applied in abeforeAll()
hook in a script specified insetupFilesAfterEnv
, but does not work if applied from within or after an async execution insidebeforeAll()
.More illustratively, with the following code the timeout gets properly registered:
However, replacing the two execution lines will prevent the timeout from being registered:
Similarly, this doesn't work either:
i.e. you end up with the infamous
Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.
error message and a test failure.To Reproduce
config.json
(i.e. jest config file) withsetupFilesAfterEnv
set to["init.js"]
.init.js
, specify abeforeAll()
as explained above - setting the timeout to over 6 seconds.Expected behavior
jest.setTimeout()
applied in the 2 failing steps mentioned above should be registered.Link to repl or repo (highly encouraged)
N/A
envinfo
The text was updated successfully, but these errors were encountered: