Closed
Description
For some reason, the second (and third, and fourth and so on) test case does not respect what is set with jest.setTimeout()
. Only the first test case does.
I've got a Jest config like this:
module.exports = {
testSequencer: './tests/e2e/util/jestSequencer.js',
projects: [
{
displayName: 'E2E',
rootDir: 'tests/e2e',
preset: 'jest-playwright-preset',
runner: '<rootDir>/util/serialJestRunner.js',
setupFilesAfterEnv: [
'<rootDir>/jest.setup.js',
'<rootDir>/util/registerAllureReporter',
],
transformIgnorePatterns: [
'/node_modules/(?!(query-selector-shadow-dom)/)',
],
},
],
};
jest.setup.js
sets jest.setTimeout(5000);
.
When running two test cases where I on purpose delay them (to replicate this), this is what I receive:
FAIL E2E tests/e2e/suite/login/login.e2e.test.js (21.387s)
\u25cf Login page \u203a has a title
: Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error:
22 | });
23 |
> 24 | it('has a title', async () => {
| ^
25 | await sleep(11000);
26 | const title = await page.title();
27 | expect(title).toBe('Login');
at new Spec (../../node_modules/jest-jasmine2/build/jasmine/Spec.js:116:22)
at Suite.<anonymous> (suite/login/login.e2e.test.js:24:3)
FAIL E2E tests/e2e/suite/login/foo.e2e.test.js (15.55s)
\u25cf Console
console.error node_modules/jest-jasmine2/build/jasmine/Env.js:248
Unhandled error
console.error node_modules/jest-jasmine2/build/jasmine/Env.js:249
Error: Protocol error (Runtime.callFunctionOn): Session closed. Most likely the page has been closed.
at CRSession.send (/home/userA/code/projectA/node_modules/playwright-core/lib/chromium/crConnection.js:121:19)
at CRSession.<anonymous> (/home/userA/code/projectA/node_modules/playwright-core/lib/helper.js:84:31)
at CRExecutionContext.evaluate (/home/userA/code/projectA/node_modules/playwright-core/lib/chromium/crExecutionContext.js:70:83)
-- ASYNC --
at Frame.<anonymous> (/home/userA/code/projectA/node_modules/playwright-core/lib/helper.js:63:23)
at Page.title (/home/userA/code/projectA/node_modules/playwright-core/lib/page.js:285:33)
at Page.title (/home/userA/code/projectA/node_modules/playwright-core/lib/helper.js:84:31)
at Object.<anonymous> (/home/userA/code/projectA/tests/e2e/suite/login/login.e2e.test.js:26:30)
\u25cf Login page \u203a has a title
Timeout - Async callback was not invoked within the 10000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 10000ms timeout specified by jest.setTimeout.
Notice the 5000ms timeout (which is what I configured) vs the 10000ms, where I have no idea where that comes from.
It can be reproduced by having two tests files with this:
const { promisify } = require('util');
const sleep = promisify(setTimeout);
beforeAll(async () => {
await page.goto(`http://example.com/`);
}, 10000);
it('sleep', async () => {
await sleep(11000);
expect(true).toBe(true);
});
Metadata
Metadata
Assignees
Labels
No labels