-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathvitest.config.base.js
More file actions
69 lines (61 loc) · 1.9 KB
/
vitest.config.base.js
File metadata and controls
69 lines (61 loc) · 1.9 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
const fs = require('fs')
const path = require('path')
const packagesDir = path.join(__dirname, 'packages')
const workspaceAliases = []
for (const dir of fs.readdirSync(packagesDir)) {
const pkgDir = path.join(packagesDir, dir)
const pkgJsonPath = path.join(pkgDir, 'package.json')
if (!fs.existsSync(pkgJsonPath)) continue
const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'))
if (!pkg.name) continue
const srcIndex = path.join(pkgDir, 'src', 'index.ts')
const srcDir = path.join(pkgDir, 'src')
if (fs.existsSync(srcDir)) {
workspaceAliases.push({
find: new RegExp(`^${pkg.name}/dist/(.*)$`),
replacement: `${srcDir}/$1`,
})
workspaceAliases.push({
find: new RegExp(`^${pkg.name}/(.*)\\.node$`),
replacement: `${srcDir}/$1/node.ts`,
})
workspaceAliases.push({
find: new RegExp(`^${pkg.name}/(.*)\\.browser$`),
replacement: `${srcDir}/$1/browser.ts`,
})
workspaceAliases.push({
find: new RegExp(`^${pkg.name}/(.*)$`),
replacement: `${srcDir}/$1`,
})
}
if (fs.existsSync(srcIndex)) {
workspaceAliases.push({ find: pkg.name, replacement: srcIndex })
} else if (fs.existsSync(srcDir)) {
workspaceAliases.push({ find: pkg.name, replacement: srcDir })
}
}
module.exports = {
cache: {
dir: path.join(__dirname, 'node_modules/.vitest-cache'),
},
resolve: {
alias: workspaceAliases,
},
test: {
globals: true,
setupFiles: [path.join(__dirname, 'vitest.setup.ts')],
include: ['**/__tests__/**/*.{test,spec}.{ts,tsx,js,jsx}', '**/*.{test,spec}.{ts,tsx,js,jsx}'],
exclude: ['**/node_modules/**', '**/examples/**'],
coverage: {
provider: 'v8',
exclude: ['**/examples/**', '**/node_modules/**', '**/__tests__/**'],
thresholds: {
branches: 90,
functions: 95,
lines: 95,
statements: 95,
},
include: ['src/**/*.{ts,tsx}'],
},
},
}