If I run vitest run --coverage
when using default's v8 system, everything works, and I get a proper text table with the coverage. But if I use now Istanbul instead, I get an error:
> 2024-03-sveltekit@0.0.1 coverage> VITE_COVERAGE=true vitest run --coverage23:55:17 [vite-plugin-svelte] You are using Svelte 5.0.0-next.123. Svelte 5 support is experimental, breaking changes can occur in any release until this notice is removed.work in progress: - svelte-inspector is disabled until dev mode implements node to code mapping RUN v1.6.0 /home/leo/Documents/Informatique/Programmation/Projects/2023_05_15_-_Maman_planning/web_interface/2024_03_sveltekit Coverage enabled with istanbul(node:1338588) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.(Use `node --trace-deprecation ...` to show where the warning was created)(node:1338588) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.(Use `node --trace-deprecation ...` to show where the warning was created)stdout | src/routes/home.test.js:21:9en-US✓ src/lib/database/db.test.js (9)✓ src/routes/home.test.js (1) Test Files 2 passed (2) Tests 10 passed (10) Start at 23:55:17 Duration 2.41s (transform 1.10s, setup 1ms, collect 2.23s, tests 53ms, environment 646ms, prepare 175ms)⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Error ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯Error: Failed to resolve import "$app/stores" from "src/routes/file/[fileUuid]/+page.svelte?v=1718315720519". Does the file exist?1267| $.mark_module_start();1268| import * as $ from "svelte/internal/client";1269| import { page } from "$app/stores"; | ^
Do you know how to fix this?
I have so far:
vitest.config.js
:
import { defineConfig } from 'vite';import { svelte } from '@sveltejs/vite-plugin-svelte';import { resolve, dirname } from 'node:path'import { fileURLToPath } from 'node:url'import { configDefaults } from 'vitest/config'export default defineConfig({ plugins: [svelte()], test: { globals: true, exclude:[ ...configDefaults.exclude, '.direnv','tests/playwright/**/*' ], coverage: { provider: 'istanbul', // or 'v8' reporter: ['text'] }, environment: 'jsdom', alias: [ { find: /\$lib/, replacement: resolve(fileURLToPath(dirname(import.meta.url)), '/src/lib'), } ] }});
vite.config.ts
import { sveltekit } from '@sveltejs/kit/vite';import { defineConfig } from 'vite';import istanbul from 'vite-plugin-istanbul';export default defineConfig({ plugins: [ sveltekit(), istanbul({ include: 'src/*', exclude: ['node_modules', 'tests/'], extension: ['.js', '.ts', '.svelte'], // VITE_COVERAGE=true to enable the plugin requireEnv: true }), ]});