Nuxt vitest does not run any tests at all

  Kiến thức lập trình

I have a new nuxt 3 project and when I tried to add to test modes to my package.json

scripts:{  
    "test": "vitest",
    "test:dev": "vitest --config ./vitest.dev.config.ts"
  },

I have 2 config files for vitest at the root.

vitest.config.ts and vitest.dev.config.ts

The first is configured to output to a junit.xml file using a reporter and this works ok. I want to use this in my Jenkins pipeline.

The second does nothing. The only difference is that the reporter section is removed.

vitest.dev.config.ts

import { defineVitestConfig } from '@nuxt/test-utils/config';

export default defineVitestConfig({
  // any custom Vitest config you require
  test: {
    include: ['./tests/**/*.test.ts'],
    exclude: [
      './docker/', 
      './.nuxt/'
    ],
    environment: 'nuxt',
    //environment: 'happy-dom',
    globals: true,
  },
  resolve: {
    alias: {
      '~': __dirname
    }
  }
})

When I run this from cli I get the following output :

npm run test:dev

> test:dev
> vitest --config ./vitest.dev.config.ts

[nuxt] modules:before: 0.176ms
[nuxt] kit:compatibility: 11.764ms
[nuxt] kit:compatibility: 11.796ms
[nuxt] kit:compatibility: 11.773ms
[nuxt] kit:compatibility: 11.687ms
[nuxt] kit:compatibility: 11.685ms
[nuxt] kit:compatibility: 11.701ms
[nuxt] kit:compatibility: 11.829ms
[nuxt] kit:compatibility: 11.829ms
[nuxt] kit:compatibility: 11.89ms
[nuxt] kit:compatibility: 11.782ms
[nuxt] kit:compatibility: 11.776ms
[nuxt] kit:compatibility: 0.03ms
[nuxt] kit:compatibility: 0.095ms
[nuxt] kit:compatibility: 0.173ms
[nuxt] pages:routerOptions: 0.023ms
[nuxt] kit:compatibility: 0.016ms
[nuxt] kit:compatibility: 0.485ms
[nuxt] kit:compatibility: 0.535ms
[nuxt] kit:compatibility: 0.629ms
[nuxt] kit:compatibility: 0.635ms
[nuxt] kit:compatibility: 0.635ms
[nuxt] kit:compatibility: 0.634ms
[nuxt] kit:compatibility: 0.633ms
[nuxt] kit:compatibility: 0.635ms
[nuxt] kit:compatibility: 0.642ms
[nuxt] kit:compatibility: 0.602ms
[nuxt] imports:sources: 0.149ms
[nuxt] imports:context: 0.463ms
[nuxt] imports:dirs: 0.058ms
[nuxt] imports:extend: 0.1ms
[nuxt] builder:generateApp: 0.012ms
[nuxt] schema:extend: 0.019ms
[nuxt] schema:resolved: 0.008ms
[nuxt] modules:done: 6.521ms
[nuxt] kit:compatibility: 3.602ms
[nuxt] nitro:config: 0.119ms
[nuxt] nitro:init: 0.144ms
[nuxt] ready: 0.293ms
[nuxt] components:dirs: 0.012ms
[nuxt] app:resolve: 1.254ms
[nuxt] pages:extend: 0.26ms
[nuxt] components:extend: 0.161ms
[nuxt] app:templates: 8.866ms
[nuxt] eslint:config:addons: 8.064ms
[nuxt] pages:routerOptions: 0.103ms
[nuxt] imports:extend: 0.121ms
[nuxt] builder:generateApp: 0.009ms
[nuxt] app:templatesGenerated: 4.455ms
[nuxt] build:before: 24.16ms
[nuxt] schema:beforeWrite: 0.01ms
[nuxt] schema:written: 0.019ms
[nuxt] nitro:build:before: 0.072ms
[nuxt] prerender:routes: 0.01ms
[nitro] prerender:routes: 0.197ms
[success] [nitro] Generated public .output/public
[nuxt] nitro:build:public-assets: 0.027ms
[nitro] rollup:before: 16.827ms
[nitro] types:extend: 0.02ms
[info] [nitro] Building Nuxt Nitro server (preset: `node-server`)
[success] [nitro] Nuxt Nitro server built
  ├─ .output/server/chunks/_/error-500.mjs (4.82 kB) (2.04 kB gzip)
  ├─ .output/server/chunks/_/error-500.mjs.map (190 B) (157 B gzip)
  ├─ .output/server/chunks/build/client.manifest.mjs (2.18 kB) (488 B gzip)
  ├─ .output/server/chunks/build/client.manifest.mjs.map (1.98 kB) (394 B gzip)
  ├─ .output/server/chunks/routes/renderer.mjs (12.2 kB) (4.01 kB gzip)
  ├─ .output/server/chunks/routes/renderer.mjs.map (390 B) (214 B gzip)
  ├─ .output/server/chunks/runtime.mjs (166 kB) (40.6 kB gzip)
  ├─ .output/server/chunks/runtime.mjs.map (3.01 kB) (770 B gzip)
  ├─ .output/server/chunks/virtual/_virtual_spa-template.mjs (94 B) (100 B gzip)
  ├─ .output/server/chunks/virtual/_virtual_spa-template.mjs.map (112 B) (111 B gzip)
  ├─ .output/server/index.mjs (291 B) (192 B gzip)
  └─ .output/server/package.json (608 B) (300 B gzip)
Σ Total size: 1.57 MB (378 kB gzip)
[nitro] compiled: 0.022ms
[success] [nitro] You can preview this build using `node .output/server/index.mjs`

It looks like nitro is compiling the app. Fine, I guess. But why is it not running my unit tests? Or reporting that no unit tests were found?

Vitest is behaving very weirdly, in the way of doing nothing at all that it is supposed to do.

What am I missing here?

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT