-
Notifications
You must be signed in to change notification settings - Fork 1
/
vitest.config.mts
30 lines (27 loc) · 980 Bytes
/
vitest.config.mts
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
import { globSync } from 'glob';
import { dirname, extname, join, relative } from 'node:path';
import { defineConfig, mergeConfig } from 'vitest/config';
import { configDefaults } from 'vitest/config';
import workspace from './vitest.workspace.mts';
import base from './packages/build-config/templates/vite/base.vitest.config';
export default mergeConfig(
base,
defineConfig({
test: {
coverage: {
provider: 'v8',
reporter: ['lcovonly', 'text'],
include: getWorkspaceProjects(workspace).flatMap((projectPath) =>
(configDefaults.coverage.include ?? ['**']).map((pattern) => join(projectPath, pattern)),
),
},
},
}),
);
function getWorkspaceProjects(workspacePaths: Array<string>) {
return workspacePaths.flatMap((project) =>
globSync(join(__dirname, project))
.map((projectPath) => (extname(projectPath) ? dirname(projectPath) : projectPath))
.map((path) => relative(__dirname, path)),
);
}