Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions examples/app-vitest-workspace/app1/test/app.browser.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { describe, expect, it } from 'vitest'
import { mountSuspended } from '@nuxt/test-utils/runtime'

import { NuxtLink } from '#components'

describe('app', () => {
it('useAppConfig', () => {
expect(Object.keys(useAppConfig())).toEqual(['nuxt'])
})
Comment on lines +7 to +9

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Avoid strict full-key equality for useAppConfig() in this smoke test.

This assertion is brittle to unrelated config growth and can fail even when browser+Nuxt setup works. Assert the presence of the nuxt key instead.

Suggested patch
-    expect(Object.keys(useAppConfig())).toEqual(['nuxt'])
+    expect(useAppConfig()).toHaveProperty('nuxt')
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/app-vitest-workspace/app1/test/app.browser.spec.ts` around lines 7 -
9, The assertion in the useAppConfig test block is checking for exact key
equality with toEqual(['nuxt']), which is brittle because it will fail if any
additional unrelated config keys are added. Instead of checking for exact
equality of all keys, change the expectation to use toContain('nuxt') to assert
only that the 'nuxt' key is present in the returned config object, making the
smoke test more resilient to future config additions.


it('mountSuspended', async () => {
const wrapper = await mountSuspended(NuxtLink, {
slots: {
default: () => 'Hello',
},
})

expect(wrapper.text()).toBe('Hello')
})
})
20 changes: 20 additions & 0 deletions examples/app-vitest-workspace/app1/vitest.browser.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { fileURLToPath } from 'node:url'
import { defineVitestProject } from '@nuxt/test-utils/config'
import { playwright } from '@vitest/browser-playwright'

export default defineVitestProject({
test: {
name: 'browser-app1',
include: ['**/*.browser.spec.ts'],
environmentOptions: {
nuxt: {
rootDir: fileURLToPath(new URL('.', import.meta.url)),
},
},
browser: {
enabled: true,
provider: playwright(),
instances: [{ browser: 'chromium' }],
},
},
})
2 changes: 2 additions & 0 deletions examples/app-vitest-workspace/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
"devDependencies": {
"@nuxt/test-utils": "latest",
"@nuxt/ui": "4.8.2",
"@vitest/browser": "4.1.8",
"@vitest/browser-playwright": "4.1.8",
"happy-dom": "20.10.3",
"playwright-core": "1.60.0",
"typescript": "6.0.3",
Expand Down
Loading
Loading