chore: update vitest config (#12530)

This commit is contained in:
inottn
2023-12-24 20:33:56 +08:00
committed by GitHub
parent ace3311e70
commit a3180c3aaf
2 changed files with 15 additions and 7 deletions
+12 -4
View File
@@ -1,9 +1,10 @@
import { defineConfig } from 'vitest/config';
import vitePluginVue from '@vitejs/plugin-vue';
import vitePluginJsx from '@vitejs/plugin-vue-jsx';
import { cpus } from 'os';
import { cpus, totalmem } from 'os';
const cpuNum = Math.max(cpus().length - 1, 1);
const memory = totalmem();
export default defineConfig({
test: {
@@ -20,12 +21,19 @@ export default defineConfig({
reporter: ['lcov', 'text-summary'],
reportsDirectory: './test/coverage',
},
pool: 'vmThreads',
poolOptions: {
vmThreads: {
// limit the memory to avoid OOM
memoryLimit:
typeof memory === 'number'
? memory * Math.min(1 / (cpuNum * 2), 0.1)
: undefined,
},
},
environment: 'jsdom',
include: ['src/**/*.spec.[jt]s?(x)'],
restoreMocks: true,
experimentalVmThreads: true,
// limit the memory to avoid OOM
experimentalVmWorkerMemoryLimit: Math.min(1 / (cpuNum * 2), 0.1),
},
plugins: [vitePluginVue(), vitePluginJsx()],
});