mirror of
https://gitee.com/nocobase/nocobase.git
synced 2024-12-02 04:07:50 +08:00
fix: vitest config
This commit is contained in:
parent
a00f4ac69b
commit
ed26c2ebea
@ -150,7 +150,27 @@ const defineClientConfig = () => {
|
||||
};
|
||||
|
||||
export const getFilterInclude = (isServer, isCoverage) => {
|
||||
let filterFileOrDir = process.argv.slice(2).find((arg) => !arg.startsWith('-'));
|
||||
let argv = process.argv
|
||||
.slice(2);
|
||||
|
||||
argv = argv
|
||||
.filter((item, index) => {
|
||||
if (!item.startsWith('-')) {
|
||||
const pre = argv[index - 1];
|
||||
|
||||
if (pre && pre.startsWith('--') && !pre.includes('=')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
let filterFileOrDir = argv[0];
|
||||
|
||||
if (!filterFileOrDir) return {};
|
||||
const absPath = path.join(process.cwd(), filterFileOrDir);
|
||||
const isDir = fs.existsSync(absPath) && fs.statSync(absPath).isDirectory();
|
||||
@ -213,11 +233,13 @@ export const defineConfig = () => {
|
||||
);
|
||||
|
||||
const { isFile, include: filterInclude } = getFilterInclude(isServer);
|
||||
|
||||
if (filterInclude) {
|
||||
config.test.include = filterInclude;
|
||||
if (isFile) {
|
||||
// 减少收集的文件
|
||||
config.test.exclude = [];
|
||||
|
||||
config.test.coverage = {
|
||||
enabled: false,
|
||||
};
|
||||
@ -240,5 +262,6 @@ export const defineConfig = () => {
|
||||
config.test.coverage.reportsDirectory = reportsDirectory;
|
||||
}
|
||||
|
||||
|
||||
return config;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user