From 9d9ec4b294447dd0daa0efa6799e87e816dd7762 Mon Sep 17 00:00:00 2001 From: "Ray.Hao" <1490493387@qq.com> Date: Tue, 24 Mar 2026 10:50:11 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E7=A7=BB=E9=99=A4=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E4=BE=9D=E8=B5=96=E5=92=8C=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 10 -------- tests/setup.ts | 60 ------------------------------------------------ vitest.config.ts | 59 ----------------------------------------------- 3 files changed, 129 deletions(-) delete mode 100644 tests/setup.ts delete mode 100644 vitest.config.ts diff --git a/package.json b/package.json index 848fda4d..78daa88c 100644 --- a/package.json +++ b/package.json @@ -10,10 +10,6 @@ "preview": "vite preview", "build-only": "vite build", "type-check": "vue-tsc --noEmit", - "test": "vitest", - "test:ui": "vitest --ui", - "test:run": "vitest run", - "test:coverage": "vitest run --coverage", "lint:eslint": "eslint --cache \"src/**/*.{vue,ts,js}\" --fix", "lint:prettier": "prettier --write \"**/*.{js,cjs,ts,json,css,scss,vue,html,md}\"", "lint:stylelint": "stylelint --cache \"**/*.{css,scss,vue}\" --fix", @@ -79,8 +75,6 @@ "@commitlint/config-conventional": "^20.5.0", "@eslint/js": "^10.0.1", "@iconify/utils": "^3.1.0", - "@testing-library/user-event": "^14.6.1", - "@testing-library/vue": "^8.1.0", "@types/codemirror": "^5.60.17", "@types/lodash-es": "^4.17.12", "@types/node": "^25.5.0", @@ -91,8 +85,6 @@ "@typescript-eslint/eslint-plugin": "^8.57.0", "@typescript-eslint/parser": "^8.57.0", "@vitejs/plugin-vue": "^6.0.5", - "@vitest/ui": "^4.1.0", - "@vue/test-utils": "^2.4.6", "autoprefixer": "^10.4.27", "commitizen": "^4.3.1", "cz-git": "^1.12.0", @@ -101,7 +93,6 @@ "eslint-plugin-prettier": "^5.5.5", "eslint-plugin-vue": "^10.8.0", "globals": "^17.4.0", - "happy-dom": "^20.8.4", "husky": "^9.1.7", "lint-staged": "^16.4.0", "postcss": "^8.5.8", @@ -124,7 +115,6 @@ "unplugin-vue-components": "^31.0.0", "vite": "^8.0.0", "vite-plugin-mock-dev-server": "^2.1.0", - "vitest": "^4.1.0", "vue-eslint-parser": "^10.4.0", "vue-tsc": "^3.2.5" }, diff --git a/tests/setup.ts b/tests/setup.ts deleted file mode 100644 index f1928975..00000000 --- a/tests/setup.ts +++ /dev/null @@ -1,60 +0,0 @@ -/** - * 测试环境全局配置 - */ - -import { vi } from "vitest"; - -// Mock window.matchMedia -Object.defineProperty(window, "matchMedia", { - writable: true, - value: vi.fn().mockImplementation((query) => ({ - matches: false, - media: query, - onchange: null, - addListener: vi.fn(), - removeListener: vi.fn(), - addEventListener: vi.fn(), - removeEventListener: vi.fn(), - dispatchEvent: vi.fn(), - })), -}); - -// Mock IntersectionObserver -global.IntersectionObserver = class IntersectionObserver { - constructor() {} - disconnect() {} - observe() {} - takeRecords() { - return []; - } - unobserve() {} -} as any; - -// Mock ResizeObserver -global.ResizeObserver = class ResizeObserver { - constructor() {} - disconnect() {} - observe() {} - unobserve() {} -} as any; - -// Mock Element.scrollIntoView -Element.prototype.scrollIntoView = vi.fn(); - -// Mock __APP_INFO__ -(globalThis as any).__APP_INFO__ = { - pkg: { - name: "vue3-element-admin", - version: "4.0.0", - }, -}; - -// Mock console methods to reduce noise in tests -global.console = { - ...console, - log: vi.fn(), - debug: vi.fn(), - info: vi.fn(), - warn: vi.fn(), - error: vi.fn(), -}; diff --git a/vitest.config.ts b/vitest.config.ts deleted file mode 100644 index 391e3f6f..00000000 --- a/vitest.config.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { defineConfig } from "vitest/config"; -import vue from "@vitejs/plugin-vue"; -import { resolve } from "path"; -import AutoImport from "unplugin-auto-import/vite"; -import Components from "unplugin-vue-components/vite"; -import { ElementPlusResolver } from "unplugin-vue-components/resolvers"; - -export default defineConfig({ - plugins: [ - vue(), - // API 自动导入 - AutoImport({ - imports: ["vue", "@vueuse/core", "pinia", "vue-router", "vue-i18n"], - resolvers: [ElementPlusResolver()], - dts: false, - }), - // 组件自动导入 - Components({ - resolvers: [ElementPlusResolver()], - dts: false, - }), - ], - test: { - // 使用 happy-dom 作为测试环境(比 jsdom 快) - environment: "happy-dom", - - // 全局测试 API(describe, it, expect 等) - globals: true, - - // 测试环境设置文件 - setupFiles: ["./tests/setup.ts"], - - // 覆盖率配置 - coverage: { - provider: "v8", - reporter: ["text", "json", "html"], - exclude: [ - "node_modules/", - "tests/", - "**/*.d.ts", - "**/*.config.*", - "**/mockData", - "**/.{idea,git,cache,output,temp}", - ], - }, - - // 测试文件匹配规则 - include: ["tests/**/*.{test,spec}.{js,ts}"], - - // 测试超时时间 - testTimeout: 10000, - }, - - resolve: { - alias: { - "@": resolve(__dirname, "./src"), - }, - }, -});