diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 963a54b..d7a0093 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -33,6 +33,7 @@ "@testing-library/jest-dom": "^7.0.1", "@testing-library/react": "^16.3.3", "@testing-library/user-event": "^14.6.7", + "@types/node": "^22.20.3", "@types/react": "^19.2.18", "@types/react-dom": "^19.2.7", "@typescript/native": "npm:typescript@^7.0.2", @@ -5212,6 +5213,16 @@ "localforage": "*" } }, + "node_modules/@types/node": { + "version": "22.20.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.3.tgz", + "integrity": "sha512-DZmzkmwHzXrLPAXPyKNDzlIwMMUZCVacoD25ywdy5YTKGbOx/2ld+Q38Im2zJ0vBuZP5Prd3VZutKZyXwkOS8A==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.21.0" + } + }, "node_modules/@types/react": { "version": "19.2.18", "resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.18.tgz", @@ -11421,6 +11432,13 @@ "node": ">=22.19.0" } }, + "node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "dev": true, + "license": "MIT" + }, "node_modules/unicode-canonical-property-names-ecmascript": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.1.tgz", diff --git a/frontend/package.json b/frontend/package.json index 0887581..216ae9a 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -47,6 +47,7 @@ "@testing-library/jest-dom": "^7.0.1", "@testing-library/react": "^16.3.3", "@testing-library/user-event": "^14.6.7", + "@types/node": "^22.20.3", "@types/react": "^19.2.18", "@types/react-dom": "^19.2.7", "@typescript/native": "npm:typescript@^7.0.2", diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json index 8fa36e9..8e981ba 100644 --- a/frontend/tsconfig.json +++ b/frontend/tsconfig.json @@ -13,7 +13,7 @@ "skipLibCheck": true, "noEmit": true, "paths": { "@/*": ["./src/*"] }, - "types": ["vite/client", "vite-plugin-pwa/client"] + "types": ["vite/client", "vite-plugin-pwa/client", "node"] }, - "include": ["src", "test"] + "include": ["src", "test", "e2e", "vite.config.ts", "vitest.config.ts", "playwright.config.ts"] } diff --git a/frontend/vitest.config.ts b/frontend/vitest.config.ts index 5e5fc0c..40a2c9a 100644 --- a/frontend/vitest.config.ts +++ b/frontend/vitest.config.ts @@ -1,6 +1,6 @@ import { defineConfig } from "vitest/config"; -// 组件测试一律 colocate 在 src/ 组件目录(*.test.tsx);放 test/ 下的 .test.tsx 不会被任何 project 捕获 +// 组件测试一律 colocate 在 src/ 组件目录(*.test.tsx / *.test.ts);放 test/ 下的 .test.tsx 不会被任何 project 捕获 export default defineConfig({ resolve: { alias: { "@": new URL("./src", import.meta.url).pathname } }, test: { @@ -14,7 +14,7 @@ export default defineConfig({ extends: true, test: { name: "components", - include: ["src/**/*.test.tsx"], + include: ["src/**/*.test.{ts,tsx}"], environment: "jsdom", setupFiles: ["test/setup.ts"], },