Skip to content

Commit af2ddf2

Browse files
committedJan 15, 2025··
feat(e2e): add teardownTimeout option to set timeout for afterAll hook
1 parent c5ba2ba commit af2ddf2

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed
 

‎src/core/context.ts

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export function createTestContext(options: Partial<TestOptions>): TestContext {
1313
fixture: 'fixture',
1414
configFile: 'nuxt.config',
1515
setupTimeout: isWindows ? 240_000 : 120_000,
16+
teardownTimeout: 30_000,
1617
dev: !!JSON.parse(process.env.NUXT_TEST_DEV || 'false'),
1718
logLevel: 1,
1819
server: true,

‎src/core/setup/jest.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ export default async function setupJest(hooks: TestHooks) {
88
test('setup', hooks.setup, hooks.ctx.options.setupTimeout)
99
beforeEach(hooks.beforeEach)
1010
afterEach(hooks.afterEach)
11-
afterAll(hooks.afterAll, 20000)
11+
afterAll(hooks.afterAll, hooks.ctx.options.teardownTimeout)
1212
}

‎src/core/setup/vitest.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ export default async function setupVitest(hooks: TestHooks) {
99
vitest.beforeAll(hooks.setup, hooks.ctx.options.setupTimeout)
1010
vitest.beforeEach(hooks.beforeEach)
1111
vitest.afterEach(hooks.afterEach)
12-
vitest.afterAll(hooks.afterAll)
12+
vitest.afterAll(hooks.afterAll, hooks.ctx.options.teardownTimeout)
1313
}

‎src/core/types.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,14 @@ export interface TestOptions {
2828
dev: boolean
2929
/**
3030
* The amount of time (in milliseconds) to allow for `setupTest` to complete its work (which could include building or generating files for a Nuxt application, depending on the options that are passed).
31-
* @default `60000`
31+
* @default `120000` or `240000` on windows
3232
*/
3333
setupTimeout: number
34+
/**
35+
* The amount of time (in milliseconds) to allow tearing down the test environment, such as closing the browser.
36+
* @default `30000`
37+
*/
38+
teardownTimeout: number
3439
waitFor: number
3540
/**
3641
* Under the hood, Nuxt test utils uses [`playwright`](https://playwright.dev) to carry out browser testing. If this option is set, a browser will be launched and can be controlled in the subsequent test suite.

0 commit comments

Comments
 (0)
Please sign in to comment.