-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathvitest.config.js
65 lines (55 loc) · 1.97 KB
/
vitest.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { configDefaults, defineConfig } from "vitest/config";
import { svelte } from "@sveltejs/vite-plugin-svelte";
export default defineConfig(({ mode }) => ({
plugins: [
svelte({
compilerOptions: {
css: "injected",
},
preprocess: {
style: ({ content }) => {
return { code: content };
},
},
}),
],
// This is needed to make test pass after adding decorators in Purchases.
esbuild: { target: "es2022" },
// Use the test field to define test-specific configurations
test: {
// Set the environment to 'jsdom' to simulate a browser environment
environment: "jsdom",
// Set globals that your tests might depend on
globals: true,
// If you're using TypeScript
// You may need to set up Vite to handle TypeScript files
// This will depend on your project's setup
transformMode: {
web: [/.[tj]sx?$/], // RegEx to transform TypeScript and JavaScript files
},
// Specify reporters if needed (e.g., verbose, dot, json)
reporters: "default", // 'default' or an array of reporters
// If you need to extend the default jsdom environment (e.g., with a URL)
setupFiles: "./vitest.setup.js", // Path to the setup file
// Coverage configuration if you are collecting test coverage
coverage: {
provider: "istanbul", // or 'c8'
// Additional coverage configuration options...
},
// Other configurations like shims for APIs or polyfills can also be included
// ...
exclude: [...configDefaults.exclude, "examples/**"],
},
// The following configuration allows to avoid issues with Svelte's mount
// function when running tests
// Svelte error: lifecycle_function_unavailable
// `mount(...)` is not available on the server
resolve: {
conditions: mode === "test" ? ["browser"] : [],
},
define: {
"process.env.VITEST": JSON.stringify(true),
},
// If you need to define other Vite configurations, they can go here
// ...
}));