a template starter repo for sveltekit projects
1import { defineConfig } from 'vitest/config';
2import { playwright } from '@vitest/browser-playwright';
3import { sveltekit } from '@sveltejs/kit/vite';
4import path from 'node:path';
5import { fileURLToPath } from 'node:url';
6import { storybookTest } from '@storybook/addon-vitest/vitest-plugin';
7const dirname =
8 typeof __dirname !== 'undefined' ? __dirname : path.dirname(fileURLToPath(import.meta.url));
9
10// More info at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon
11export default defineConfig({
12 plugins: [sveltekit()],
13 test: {
14 expect: {
15 requireAssertions: true
16 },
17 projects: [
18 {
19 extends: './vite.config.ts',
20 test: {
21 name: 'client',
22 browser: {
23 enabled: true,
24 provider: playwright(),
25 instances: [
26 {
27 browser: 'chromium',
28 headless: true
29 }
30 ]
31 },
32 include: ['src/**/*.svelte.{test,spec}.{js,ts}'],
33 exclude: ['src/lib/server/**']
34 }
35 },
36 {
37 extends: './vite.config.ts',
38 test: {
39 name: 'server',
40 environment: 'node',
41 include: ['src/**/*.{test,spec}.{js,ts}'],
42 exclude: ['src/**/*.svelte.{test,spec}.{js,ts}']
43 }
44 },
45 {
46 extends: true,
47 plugins: [
48 // The plugin will run tests for the stories defined in your Storybook config
49 // See options at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon#storybooktest
50 storybookTest({
51 configDir: path.join(dirname, '.storybook')
52 })
53 ],
54 test: {
55 name: 'storybook',
56 browser: {
57 enabled: true,
58 headless: true,
59 provider: playwright({}),
60 instances: [
61 {
62 browser: 'chromium'
63 }
64 ]
65 }
66 }
67 }
68 ]
69 }
70});