Skip to content

Commit e8d2301

Browse files
authored
fix(config): browser setup in defineVitestProject (#1724)
1 parent 608a14e commit e8d2301

5 files changed

Lines changed: 1679 additions & 929 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { describe, expect, it } from 'vitest'
2+
import { mountSuspended } from '@nuxt/test-utils/runtime'
3+
4+
import { NuxtLink } from '#components'
5+
6+
describe('app', () => {
7+
it('useAppConfig', () => {
8+
expect(Object.keys(useAppConfig())).toEqual(['nuxt'])
9+
})
10+
11+
it('mountSuspended', async () => {
12+
const wrapper = await mountSuspended(NuxtLink, {
13+
slots: {
14+
default: () => 'Hello',
15+
},
16+
})
17+
18+
expect(wrapper.text()).toBe('Hello')
19+
})
20+
})
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { fileURLToPath } from 'node:url'
2+
import { defineVitestProject } from '@nuxt/test-utils/config'
3+
import { playwright } from '@vitest/browser-playwright'
4+
5+
export default defineVitestProject({
6+
test: {
7+
name: 'browser-app1',
8+
include: ['**/*.browser.spec.ts'],
9+
environmentOptions: {
10+
nuxt: {
11+
rootDir: fileURLToPath(new URL('.', import.meta.url)),
12+
},
13+
},
14+
browser: {
15+
enabled: true,
16+
provider: playwright(),
17+
instances: [{ browser: 'chromium' }],
18+
},
19+
},
20+
})

examples/app-vitest-workspace/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
"devDependencies": {
2222
"@nuxt/test-utils": "latest",
2323
"@nuxt/ui": "4.9.0",
24+
"@vitest/browser": "4.1.9",
25+
"@vitest/browser-playwright": "4.1.9",
2426
"happy-dom": "20.10.6",
2527
"playwright-core": "1.61.1",
2628
"typescript": "6.0.3",

0 commit comments

Comments
 (0)