forked from i18next/i18next
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvitest.workspace.mts
44 lines (38 loc) · 1.46 KB
/
vitest.workspace.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { readdirSync } from 'node:fs';
// eslint-disable-next-line import/no-extraneous-dependencies
import { defineWorkspace } from 'vitest/config';
import type { UserProjectConfigExport } from 'vitest/config';
const tsDirs = readdirSync('./test/typescript', { withFileTypes: true }).filter((dir) =>
dir.isDirectory(),
);
export default defineWorkspace(
/**
* If you need to test multiple typescript configurations (like misc) simply create a file named tsconfig.{customName}.json
* and this script will automatically create a new workspace named with the dirName followed by `customName`
*/
tsDirs.reduce<UserProjectConfigExport[]>((workspaces, dir) => {
const dirPath = `test/typescript/${dir.name}` as const;
const tsConfigFiles = readdirSync(dirPath).filter(
// Do not include temporary vitest tsconfig files
(it) => it.startsWith('tsconfig.') && it.endsWith('.json') && !it.includes('vitest-temp'),
);
tsConfigFiles.forEach((tsConfigFileName) => {
const workspaceName =
tsConfigFileName === 'tsconfig.json'
? dir.name
: `${dir.name}-${tsConfigFileName.split('.')[1]}`;
workspaces.push({
test: {
dir: `./${dirPath}`,
name: workspaceName,
typecheck: {
enabled: true,
include: [`**/${dirPath}/*.test.ts`],
tsconfig: `./${dirPath}/${tsConfigFileName}`,
},
},
});
});
return workspaces;
}, []),
);