From 897ac762a2ee7c515fd1d05392d90469eb794f23 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Sun, 5 Feb 2023 21:09:54 +0800 Subject: [PATCH 1/2] fix: add the configuration and fix the location error of the vitest report file --- template/config/vitest/package.json | 2 +- template/config/vitest/vitest.config.js | 15 +++++++++++++++ template/tsconfig/vitest/vitest.config.ts | 15 +++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 template/config/vitest/vitest.config.js create mode 100644 template/tsconfig/vitest/vitest.config.ts diff --git a/template/config/vitest/package.json b/template/config/vitest/package.json index 33b041ff..1805fd4b 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.45" 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)) + } + }) +) diff --git a/template/tsconfig/vitest/vitest.config.ts b/template/tsconfig/vitest/vitest.config.ts new file mode 100644 index 00000000..a2f57a5d --- /dev/null +++ b/template/tsconfig/vitest/vitest.config.ts @@ -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)) + } + }) +) From 34e93d731d2bc4849cda344f8eaa1e836db93a2c Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Thu, 23 Feb 2023 20:40:20 +0800 Subject: [PATCH 2/2] Delete vitest.config.ts 1. The `template/tsconfig` folder is for `tsconfig.json`s & `package.json`s only; 2. The TS version is identical to `template/config/vitest/vitest.config.js`, so it will be automatically created from the JS template according to the code at https://github.com/vuejs/create-vue/blob/9fde3d1f07a5d5e3792e4c0bf457d6e9f4af4937/index.ts#L380-L392 so this file is redundant. --- template/tsconfig/vitest/vitest.config.ts | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 template/tsconfig/vitest/vitest.config.ts diff --git a/template/tsconfig/vitest/vitest.config.ts b/template/tsconfig/vitest/vitest.config.ts deleted file mode 100644 index a2f57a5d..00000000 --- a/template/tsconfig/vitest/vitest.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -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)) - } - }) -)