chore: 升级 Vitest 5、Vite React 插件 6 和 jsdom 30,配置改为 ESM

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
margrop
2026-10-31 12:19:12 +08:00
parent 3acd607dd9
commit d11c8bbe25
8 changed files with 273 additions and 507 deletions

View File

@@ -109,7 +109,7 @@ jobs:
- name: Generate Prisma Client
run: npx prisma generate
# 低于 vitest.config.ts 中的覆盖率阈值时失败
# 低于 vitest.config.mts 中的覆盖率阈值时失败
- name: Run tests with coverage
run: npm run test:coverage

View File

@@ -38,7 +38,7 @@ npm run lint # 出现任何警告即失败
npm run test:unit
npm run test:integration
npm test # 全部 Vitest 测试
npm run test:coverage # 覆盖率,低于 vitest.config.ts 中的阈值时失败
npm run test:coverage # 覆盖率,低于 vitest.config.mts 中的阈值时失败
npm run test:e2e # Playwright
bash scripts/ci.sh # 完整 CI(要求 Node.js 22 及以上,含生产构建)
```

View File

@@ -143,7 +143,7 @@ wrongNotebook/
├── docker-compose.yml / .https.yml
├── Dockerfile / docker-entrypoint.sh
├── next.config.ts # standalone output, serverExternalPackages
├── vitest.config.ts # Vitest 配置
├── vitest.config.mts # Vitest 配置
├── playwright.config.ts # Playwright 配置
├── eslint.config.mjs # ESLint 配置
├── postcss.config.mjs # PostCSS 配置

View File

@@ -43,7 +43,7 @@ E2E 用例以非默认密码登录管理员:运行前先执行 `node scripts/p
CI 会运行 `npm run lint`,出现任何 ESLint 错误或警告都会失败。
`npm run test:coverage` 统计 `src/lib` 与 `src/app/api` 的测试覆盖率,低于 `vitest.config.ts` 中的阈值时失败;CI 会在任务摘要中显示覆盖率并上传报告。
`npm run test:coverage` 统计 `src/lib` 与 `src/app/api` 的测试覆盖率,低于 `vitest.config.mts` 中的阈值时失败;CI 会在任务摘要中显示覆盖率并上传报告。
`npm test` 运行全部 Vitest 测试。E2E 的环境要求与启动方式以仓库中的 [`playwright.config.ts`](https://github.com/margrop/wrong-notebook/blob/main/playwright.config.ts) 为准。

View File

@@ -43,7 +43,7 @@ E2E tests sign in as admin with a non-default password. Run `node scripts/prepar
CI runs `npm run lint` and fails on any ESLint error or warning.
`npm run test:coverage` measures test coverage of `src/lib` and `src/app/api` and fails below the thresholds in `vitest.config.ts`; CI shows the coverage in the job summary and uploads the report.
`npm run test:coverage` measures test coverage of `src/lib` and `src/app/api` and fails below the thresholds in `vitest.config.mts`; CI shows the coverage in the job summary and uploads the report.
`npm test` runs all Vitest tests. The E2E environment and startup are defined in the repository's [`playwright.config.ts`](https://github.com/margrop/wrong-notebook/blob/main/playwright.config.ts).

758
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -62,14 +62,14 @@
"@types/node": "^24.19.2",
"@types/react": "^19",
"@types/react-dom": "^19",
"@vitejs/plugin-react": "^5.1.1",
"@vitest/coverage-v8": "^4.1.12",
"@vitejs/plugin-react": "^6.1.2",
"@vitest/coverage-v8": "^5.0.5",
"baseline-browser-mapping": "^2.8.32",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"eslint": "^9",
"eslint-config-next": "16.4.3",
"jsdom": "^27.2.0",
"jsdom": "^30.1.3",
"lucide-react": "^1.65.0",
"prisma": "5.22.0",
"tailwind-merge": "^3.4.0",
@@ -77,7 +77,7 @@
"ts-node": "^10.9.2",
"tw-animate-css": "^1.4.0",
"typescript": "^5",
"vitest": "^4.0.15"
"vitest": "^5.0.5"
},
"prisma": {
"seed": "ts-node --compiler-options {\"module\":\"CommonJS\"} prisma/seed.ts"

View File

@@ -1,6 +1,6 @@
import { defineConfig } from 'vitest/config'
import react from '@vitejs/plugin-react'
import path from 'path'
import { fileURLToPath } from 'node:url'
export default defineConfig({
plugins: [react()],
@@ -9,7 +9,7 @@ export default defineConfig({
globals: true,
setupFiles: ['./src/__tests__/setup.ts'],
alias: {
'@': path.resolve(__dirname, './src'),
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
include: ['src/__tests__/**/*.test.ts', 'src/__tests__/**/*.test.tsx'],
exclude: ['node_modules', '.next', 'dist'],