]> git.ipfire.org Git - thirdparty/vuejs/create-vue.git/commitdiff
fix: use a standalone config file for the vitest (#227)
authorbtea <2356281422@qq.com>
Thu, 23 Feb 2023 13:26:34 +0000 (21:26 +0800)
committerGitHub <noreply@github.com>
Thu, 23 Feb 2023 13:26:34 +0000 (21:26 +0800)
Co-authored-by: Haoqun Jiang <haoqunjiang@gmail.com>
Fixes #221
Fixes #199

template/config/vitest/package.json
template/config/vitest/vitest.config.js [new file with mode: 0644]

index 57a87462f69b037683f0bd58ac63a5fb2a2f02e5..7bae92960f7750d3871d3d976c44763beac05505 100644 (file)
@@ -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 (file)
index 0000000..a2f57a5
--- /dev/null
@@ -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))
+    }
+  })
+)