-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvitest.config.ts
More file actions
51 lines (49 loc) · 1.77 KB
/
Copy pathvitest.config.ts
File metadata and controls
51 lines (49 loc) · 1.77 KB
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
import { resolve } from 'node:path'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import { defineConfig } from 'vitest/config'
// Deliberately not `mergeConfig(viteConfig, …)`: the app config pulls in the
// Laravel, Tailwind and PWA plugins, which need a running dev server / build
// pipeline. Tests only need the pieces that change how modules resolve and
// compile — the alias, the Vue SFC compiler and the auto-imports that
// composables and components rely on at authoring time.
export default defineConfig({
plugins: [
AutoImport({
imports: [
'vue',
'vue-router',
{
'~/env': ['useRuntimeConfig'],
},
],
// The checked-in d.ts is generated by the app config; regenerating it
// from the (smaller) test config would churn it on every test run.
dts: false,
dirs: ['resources/js/composables', 'resources/js/plugins'],
vueTemplate: true,
}),
vue(),
],
resolve: {
alias: {
'~': resolve(__dirname, 'resources/js'),
'@': resolve(__dirname, 'resources/js'),
},
},
test: {
// jsdom rather than happy-dom: `~/lib/sanitize` runs DOMPurify, and
// happy-dom's parser mangles the fragments enough that sanitization
// silently no-ops — a security helper must be tested on a faithful DOM.
environment: 'jsdom',
// No globals: every test imports describe/it/expect explicitly, so the
// checked-in tsconfig needs no extra ambient types to typecheck them.
include: ['tests/js/**/*.test.ts'],
setupFiles: ['tests/js/setup.ts'],
coverage: {
provider: 'v8',
include: ['resources/js/lib/**', 'resources/js/utils/**', 'resources/js/composables/**'],
reporter: ['text', 'html'],
},
},
})