From 89a84035c3bf85bfc66641da596148559c74a9c7 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Thu, 23 Feb 2023 21:26:34 +0800 Subject: [PATCH] fix: use a standalone config file for the vitest (#227) Co-authored-by: Haoqun Jiang Fixes #221 Fixes #199 --- template/config/vitest/package.json | 2 +- template/config/vitest/vitest.config.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 template/config/vitest/vitest.config.js diff --git a/template/config/vitest/package.json b/template/config/vitest/package.json index 57a87462..7bae9296 100644 --- a/template/config/vitest/package.json +++ b/template/config/vitest/package.json @@ -1,6 +1,6 @@ { "scripts": { - "test:unit": "vitest --environment jsdom --root src/" + "test:unit": "vitest" }, "dependencies": { "vue": "^3.2.47" diff --git a/template/config/vitest/vitest.config.js b/template/config/vitest/vitest.config.js new file mode 100644 index 00000000..a2f57a5d --- /dev/null +++ b/template/config/vitest/vitest.config.js @@ -0,0 +1,15 @@ +import { fileURLToPath } from 'node:url' +import { mergeConfig } from 'vite' +import { configDefaults, defineConfig } from 'vitest/config' +import viteConfig from './vite.config' + +export default mergeConfig( + viteConfig, + defineConfig({ + test: { + environment: 'jsdom', + exclude: [...configDefaults.exclude, 'e2e/*'], + root: fileURLToPath(new URL('./', import.meta.url)) + } + }) +) -- 2.39.5