Skip to content

Commit

Permalink
feat(e2e): add teardownTimeout option to set timeout for afterAll
Browse files Browse the repository at this point in the history
… hook
  • Loading branch information
danielroe committed Jan 15, 2025
1 parent c5ba2ba commit af2ddf2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/core/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export function createTestContext(options: Partial<TestOptions>): TestContext {
fixture: 'fixture',
configFile: 'nuxt.config',
setupTimeout: isWindows ? 240_000 : 120_000,
teardownTimeout: 30_000,
dev: !!JSON.parse(process.env.NUXT_TEST_DEV || 'false'),
logLevel: 1,
server: true,
Expand Down
2 changes: 1 addition & 1 deletion src/core/setup/jest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ export default async function setupJest(hooks: TestHooks) {
test('setup', hooks.setup, hooks.ctx.options.setupTimeout)
beforeEach(hooks.beforeEach)
afterEach(hooks.afterEach)
afterAll(hooks.afterAll, 20000)
afterAll(hooks.afterAll, hooks.ctx.options.teardownTimeout)
}
2 changes: 1 addition & 1 deletion src/core/setup/vitest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ export default async function setupVitest(hooks: TestHooks) {
vitest.beforeAll(hooks.setup, hooks.ctx.options.setupTimeout)
vitest.beforeEach(hooks.beforeEach)
vitest.afterEach(hooks.afterEach)
vitest.afterAll(hooks.afterAll)
vitest.afterAll(hooks.afterAll, hooks.ctx.options.teardownTimeout)
}
7 changes: 6 additions & 1 deletion src/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,14 @@ export interface TestOptions {
dev: boolean
/**
* 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).
* @default `60000`
* @default `120000` or `240000` on windows
*/
setupTimeout: number
/**
* The amount of time (in milliseconds) to allow tearing down the test environment, such as closing the browser.
* @default `30000`
*/
teardownTimeout: number
waitFor: number
/**
* 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.
Expand Down

0 comments on commit af2ddf2

Please sign in to comment.