You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After adding @nuxt/test-utils/module to nuxt.config.ts, the vitest.config.ts file in the root directory is not automatically loaded. Even when explicitly specifying vitestConfig.config in the testUtils property, the vitest.config.ts is not being applied.
I have observed a difference in the results when running tests directly with vitest and running them via nuxt dev.
$ vitest run
✓ server/tests/included-test.test.ts (1)
✓ included-test (1)
✓ should work
Test Files 1 passed (1)
Tests 1 passed (1)
Start at 03:26:12
Duration 374ms (transform 94ms, setup 118ms, collect 3ms, tests 1ms, environment 68ms, prepare 99ms)
$ nuxt dev
UI started at http://localhost:15555/__vitest__/
ℹ Vite server warmed up in 661ms 5:19:46 AM
❯ server/tests/-ignored-test.test.ts (1)
❯ ignored-test (1)
× this test should be ignored
✓ server/tests/included-test.test.ts (1)
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
FAIL server/tests/-ignored-test.test.ts > ignored-test > this test should be ignored
AssertionError: expected true to be false // Object.is equality
- Expected
+ Received
- false
+ true
❯ server/tests/-ignored-test.test.ts:5:18
3| describe("ignored-test", () => {
4| it("this test should be ignored", () => {
5| expect(true).toBe(false);
| ^
6| });
7| });
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯
Test Files 1 failed | 1 passed (2)
Tests 1 failed | 1 passed (2)
Start at 05:19:46
Duration 433ms (transform 443ms, setup 73ms, collect 438ms, tests 6ms, environment 0ms, prepare 115ms)
Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered:
Hey there, @jinyongp! 👋 I'm here to help you out with any bugs, questions, or becoming a contributor. Let's squash those bugs together!
To ensure that the vitest.config.ts file is automatically loaded when using @nuxt/test-utils/module in your Nuxt 3 project, you should define the configuration using defineVitestConfig from @nuxt/test-utils/config. Here is an example configuration:
Additionally, ensure that your nuxt.config.ts is correctly set up to include the @nuxt/test-utils/module and the testUtils property:
// nuxt.config.tsexportdefaultdefineNuxtConfig({devtools: {enabled: true},modules: ['@nuxt/test-utils/module'],testUtils: {startOnBoot: true,logToConsole: true,vitestConfig: {// No need to specify the config path here}}})
If the vitest.config.ts is still not being applied, make sure that your vitest.config.ts file is named correctly and located in the root directory of your project. Also, ensure that your package.json has "type": "module" specified, or rename your configuration file to vitest.config.mts if you are using TypeScript.
If you continue to experience issues, it might be related to a known issue where the vitest.config.ts file is not automatically loaded. In such cases, you can explicitly import and apply the configuration in your nuxt.config.ts:
Environment
Reproduction
Reproduction on CodeSandbox
Describe the bug
After adding
@nuxt/test-utils/module
tonuxt.config.ts
, thevitest.config.ts
file in the root directory is not automatically loaded. Even when explicitly specifyingvitestConfig.config
in thetestUtils
property, thevitest.config.ts
is not being applied.Here is the configuration:
I have observed a difference in the results when running tests directly with vitest and running them via nuxt dev.
Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered: