Skip to content

Commit 4b90de9

Browse files
committed
fix(config): browser setup in defineVitestProject
1 parent e1a0f63 commit 4b90de9

5 files changed

Lines changed: 815 additions & 194 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.8.2",
24+
"@vitest/browser": "4.1.8",
25+
"@vitest/browser-playwright": "4.1.8",
2426
"happy-dom": "20.10.3",
2527
"playwright-core": "1.60.0",
2628
"typescript": "6.0.3",

0 commit comments

Comments
 (0)