Skip to content

chore: convert from jest to vitest v4.1.0#463

Draft
Copilot wants to merge 1 commit intomainfrom
copilot/convert-jest-to-vitest
Draft

chore: convert from jest to vitest v4.1.0#463
Copilot wants to merge 1 commit intomainfrom
copilot/convert-jest-to-vitest

Conversation

Copy link
Contributor

Copilot AI commented Mar 20, 2026

Summary

Migrates the test framework from Jest (v30) to Vitest (v4.1.0), the latest version.

Changes

Dependencies

  • Removed: jest (^30.1.3), ts-jest (^29.1.4), @types/jest (^30.0.0)
  • Added: vitest (^4.1.0), @vitest/coverage-v8 (^4.1.0)
  • Removed test-exclude override from package.json (was only needed by Jest's coverage tooling)

Configuration

  • Added vitest.config.ts with equivalent settings:
    • globals: true — provides test, describe, it, test.each globals (matching Jest behavior)
    • include: ["**/*[tT]est.ts"] — same test file matching pattern
    • testTimeout: 100000 — same 100s timeout
    • coverage.enabled: true — same as Jest's collectCoverage: true
  • Removed jest config section from package.json
  • Updated ts.test script from jest to vitest run

TypeScript Configuration

  • Added "types": ["vitest/globals"] to tsconfig.json (replaces @types/jest)
  • Added "skipLibCheck": true (needed because vitest's type declarations use modern exports that require node16/bundler module resolution, while this project uses legacy commonjs module resolution)
  • Added vitest.config.ts to exclude (required because rootDir is ./src)
  • Added vitest.config.ts to eslint ignores

Source Change

  • src/index.ts: Converted require("./lib/util/constants") to export { Constants } from "./lib/util/constants" — vitest's ESM-based module resolution doesn't support bare require() calls to TypeScript source files without extensions

Verification

  • npm run tsc — builds successfully
  • npm run lint — no warnings
  • npm run prettier — all files formatted
  • npm run ts.test — 5/5 non-.NET tests pass (18 tests that require dotnet DLLs fail as expected in this environment, same as with Jest)
  • ✅ No security vulnerabilities (CodeQL clean)

Migration Notes

  • No test files were modified — all tests use standard test()/describe()/it() globals and Node.js assert module, which are compatible between Jest and Vitest
  • The test.each() API used in incompatiblePropertiesTest.ts works identically in Vitest

- Replace jest, ts-jest, @types/jest with vitest and @vitest/coverage-v8
- Add vitest.config.ts with globals, test matching, timeout, and coverage
- Update package.json scripts (ts.test: vitest run)
- Remove jest config from package.json
- Remove test-exclude override (no longer needed)
- Convert require() to import in src/index.ts for vitest compatibility
- Add vitest/globals types and skipLibCheck to tsconfig.json
- Exclude vitest.config.ts from tsc and eslint

Co-authored-by: mikeharder <9459391+mikeharder@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants