-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
vitest.workspace.ts
36 lines (34 loc) · 1.03 KB
/
vitest.workspace.ts
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
import { fileURLToPath } from 'node:url'
import { defineWorkspace } from 'vitest/config'
import { globbySync } from 'globby'
import fs from 'node:fs'
const pluginsProjects = globbySync('./plugins/*', { onlyDirectories: true })
.map((dir) => {
try {
const pkg = JSON.parse(fs.readFileSync(fileURLToPath(new URL(`${dir}/package.json`, import.meta.url)), 'utf-8'))
return {
name: pkg.name,
root: dir,
}
} catch (error) {
console.error(`Error reading package.json from "${dir}"`, error)
return null
}
})
.filter((v) => v != null)
export default defineWorkspace([
// you can use a list of glob patterns to define your workspaces
// Vitest expects a list of config files
// or directories where there is a config file
'.',
// './plugins/*',
// you can even run the same tests,
// but with different configs in the same "vitest" process
// () => ({}),
...pluginsProjects.map((project) => ({
extends: './vitest.config.ts',
test: {
...project,
},
})),
])