From 36c35864d32b8dd95c982d34e345e3ab1992467f Mon Sep 17 00:00:00 2001 From: tiennm99 Date: Tue, 15 Sep 2026 10:06:46 +0700 Subject: [PATCH] test: let vitest import svelte rune modules Adds the svelte plugin and the $lib alias so *.svelte.js modules can be imported by tests. The lesson interaction logic was untestable without it. --- vitest.config.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/vitest.config.js b/vitest.config.js index 4175afd..fc7aeea 100644 --- a/vitest.config.js +++ b/vitest.config.js @@ -1,6 +1,18 @@ +import { fileURLToPath } from 'node:url'; import { defineConfig } from 'vitest/config'; +import { svelte } from '@sveltejs/vite-plugin-svelte'; export default defineConfig({ + // The svelte plugin is what lets `*.svelte.js` rune modules be imported by + // tests; without it the interaction modules are untestable. + plugins: [svelte()], + resolve: { + conditions: ['browser'], + // SvelteKit normally injects $lib; vitest runs without that layer. + alias: { + $lib: fileURLToPath(new URL('./src/lib', import.meta.url)), + }, + }, test: { include: ['src/**/*.test.js'], environment: 'node',