forked from sveltejs/svelte
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vitest.config.js
50 lines (46 loc) · 1.23 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
import * as fs from 'node:fs';
import * as path from 'node:path';
import { configDefaults, defineConfig } from 'vitest/config';
const pkg = JSON.parse(fs.readFileSync('packages/svelte/package.json', 'utf8'));
export default defineConfig({
// We need both a plugin and an alias for some reason
resolve: {
alias: [
{
find: /^svelte\/?/,
customResolver: (id) => {
// For some reason this turns up as "undefined" instead of "svelte"
const exported = pkg.exports[id.replace('undefined', '.')];
if (!exported) return;
return path.resolve('packages/svelte', exported.browser ?? exported.default);
}
}
]
},
plugins: [
{
name: 'resolve-svelte',
resolveId(id) {
if (/^svelte\/?/.test(id)) {
const exported = pkg.exports[id.replace('svelte', '.')];
if (!exported) return;
return path.resolve('packages/svelte', exported.browser ?? exported.default);
}
}
}
],
test: {
dir: '.',
reporters: ['dot'],
include: [
'packages/svelte/**/*.test.ts',
'packages/svelte/tests/*/test.ts',
'packages/svelte/tests/runtime-browser/test-ssr.ts'
],
exclude: [...configDefaults.exclude, '**/samples/**'],
coverage: {
provider: 'v8',
reporter: ['lcov', 'html']
}
}
});