Skip to content

Commit

Permalink
build: config for vitest / svelte with testinglibrary and jestdom
Browse files Browse the repository at this point in the history
  • Loading branch information
bdromard committed Dec 12, 2024
1 parent 0799e17 commit eb36211
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"format": "prettier --write .",
"lint": "prettier --check . && eslint .",
"test:unit": "vitest",
"test": "npm run test:unit -- --run"
"test": "vitest run"
},
"devDependencies": {
"@sveltejs/adapter-auto": "^3.0.0",
Expand Down
4 changes: 3 additions & 1 deletion dashboard/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"extends": "./.svelte-kit/tsconfig.json",
"include": ["src/**/*.d.ts", "src/**/*.ts", "src/**/*.js", "src/**/*.svelte", "./vitest-setup.ts"],
"compilerOptions": {
"allowJs": true,
"checkJs": true,
Expand All @@ -9,7 +10,8 @@
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"moduleResolution": "bundler"
"moduleResolution": "bundler",
"types": ["vitest/globals", "@testing-library/jest-dom"]
}
// Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias
// except $lib which is handled by https://svelte.dev/docs/kit/configuration#files
Expand Down
7 changes: 5 additions & 2 deletions dashboard/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { defineConfig } from 'vitest/config';
import { sveltekit } from '@sveltejs/kit/vite';
import { svelteTesting } from '@testing-library/svelte/vite';

export default defineConfig({
plugins: [sveltekit()],
plugins: [sveltekit(), svelteTesting()],

test: {
include: ['src/**/*.{test,spec}.{js,ts}']
include: ['src/**/*.{test,spec}.{js,ts}'],
environment: 'jsdom',
setupFiles: ['./vitest-setup.ts']
}
});
1 change: 1 addition & 0 deletions dashboard/vitest-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "@testing-library/jest-dom/vitest";

0 comments on commit eb36211

Please sign in to comment.