Skip to content

Commit

Permalink
feat(e2e): auto-detect jest runner
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Dec 18, 2023
1 parent 9451393 commit ae37b0e
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 7 deletions.
1 change: 0 additions & 1 deletion examples/app-jest/test/browser.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { createPage, setup } from '@nuxt/test-utils/e2e'
await setup({
rootDir: fileURLToPath(new URL('../', import.meta.url)),
browser: true,
runner: 'jest',
})

describe('browser', () => {
Expand Down
1 change: 0 additions & 1 deletion examples/app-jest/test/dev.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { $fetch, setup } from '@nuxt/test-utils/e2e'
await setup({
rootDir: fileURLToPath(new URL('../', import.meta.url)),
dev: true,
runner: 'jest',
})

describe('server (dev)', () => {
Expand Down
1 change: 0 additions & 1 deletion examples/app-jest/test/server.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { $fetch, setup } from '@nuxt/test-utils/e2e'

await setup({
rootDir: fileURLToPath(new URL('../', import.meta.url)),
runner: 'jest'
})

describe("app",()=>{
Expand Down
7 changes: 3 additions & 4 deletions src/core/context.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { resolve } from 'node:path'
import { defu } from 'defu'
import type { TestContext, TestOptions, TestRunner } from './types'
import type { TestContext, TestOptions } from './types'

let currentContext: TestContext | undefined

Expand All @@ -15,12 +15,11 @@ export function createTestContext (options: Partial<TestOptions>): TestContext {
server: true,
build: (options.browser !== false) || (options.server !== false),
nuxtConfig: {},
// TODO: auto detect based on process.env
runner: <TestRunner>'vitest',
runner: process.env.VITEST === 'true' ? 'vitest' : 'jest',
browserOptions: {
type: 'chromium' as const
}
})
} satisfies Partial<TestOptions>)

return setTestContext({
options: _options as TestOptions
Expand Down

0 comments on commit ae37b0e

Please sign in to comment.