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

Move jest timeout outside test #714

Merged
merged 3 commits into from
Dec 8, 2020
Merged

Move jest timeout outside test #714

merged 3 commits into from
Dec 8, 2020

Conversation

bidoubiwa
Copy link
Contributor

@bidoubiwa bidoubiwa commented Dec 7, 2020

Because #713 also timeoud like usual I dig into the same problem again.
I think maybe it is due to the fact that it is not the tests that timeout but the whole jest setup.
So I tried following this stack overflow:
https://stackoverflow.com/questions/49603939/message-async-callback-was-not-invoked-within-the-5000-ms-timeout-specified-by

who suggests the following:

But this would be specific to the test. Or you can set up the configuration file for the framework.

Configuring Jest

// jest.config.js
module.exports = {
// setupTestFrameworkScriptFile has been deprecated in
// favor of setupFilesAfterEnv in jest 24
setupFilesAfterEnv: ['./jest.setup.js']
}

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

await page.waitForSelector("#indexes")
await expect(
page.content()
).resolves.toMatch('createdIndexTest')
}, 10000)
}, 30000)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you remind me the difference between this 30000 and the one in the jest-setup.js file please? (sorry)

@bidoubiwa
Copy link
Contributor Author

bidoubiwa commented Dec 8, 2020

The timeout you specify here needs to be shorter than the default timeout.

The 30000 in the test function was greater than the default timeout of jest which is at 5000. So it was not taken into account.

The 30000 on the test function is linked to the specific test, which means that the test can not take longer than 30000 ms. The jest.timeout function is a global timeout for all tests.

It is not stated clearly in the docs, I'm not sure if I should leave that number in both function:

similarities here: jestjs/jest#5055 (comment)
jestjs/jest#5055 (comment)

@curquiza
Copy link
Member

curquiza commented Dec 8, 2020

The 30000 on the test function is linked to the specific test, which means that the test can not take longer than 30000 ms. The jest.timeout function is a global timeout for all tests.

So what is the point to add a timeout of 30000 specific to the test if the default timeout value is already exactly 30000? I would understand if you would have added a value of 40000 specific to the test, for example.

@bidoubiwa
Copy link
Contributor Author

Yes, sorry I was editing my previous comment. Let's remove and figure out if that fixes the issue. If not I'll make an issue on their repo

@curquiza
Copy link
Member

curquiza commented Dec 8, 2020

bors try

bors bot added a commit that referenced this pull request Dec 8, 2020
@bors
Copy link
Contributor

bors bot commented Dec 8, 2020

Copy link
Member

@curquiza curquiza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I let you merge @bidoubiwa!

@bidoubiwa
Copy link
Contributor Author

bors merge

@bors
Copy link
Contributor

bors bot commented Dec 8, 2020

@bors bors bot merged commit 9dc9cee into master Dec 8, 2020
@bors bors bot deleted the timeout-outside-test branch December 8, 2020 09:52
@curquiza curquiza added the skip-changelog The PR will not appear in the release changelogs label Dec 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-changelog The PR will not appear in the release changelogs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants