Skip to content

chore: migrate from jest to vitest#133

Open
ahmed-anas wants to merge 1 commit intomasterfrom
ahmed-anas/PLAT-350/jest-to-vitest
Open

chore: migrate from jest to vitest#133
ahmed-anas wants to merge 1 commit intomasterfrom
ahmed-anas/PLAT-350/jest-to-vitest

Conversation

@ahmed-anas
Copy link
Copy Markdown

Summary

  • Migrates test framework from Jest to Vitest
  • Replaces jest.* calls with vi.* equivalents
  • Creates vitest.config.ts replacing jest.config
  • Updates test script in package.json

Why

Company-wide standardization on Vitest for faster test execution and better DX (PLAT-350).

Test plan

  • All existing tests pass with vitest
  • CI pipeline passes
  • No jest dependencies remain

Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 27, 2026

Walkthrough

This pull request migrates the testing framework from Jest to Vitest. The migration includes removing the Jest configuration file, updating the test script in package.json to run vitest run instead of jest, removing Jest-related dev dependencies (jest, ts-jest, @types/jest, jest-junit, and related mixmax packages), and adding Vitest equivalents (vitest and @vitest/coverage-v8). A new vitest.config.ts file is created with equivalent configuration settings for mock clearing and code coverage reporting. The test file is updated to import Vitest functions explicitly, and ESLint configuration for the test directory is adjusted from a Jest-specific ruleset to a generic Node ruleset.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description lacks the required sections from the template: Context/Description, Potential Risks & What To Monitor, How Has This Been Tested, and Release Plan are either missing or incomplete. Fill in all template sections: expand Context with detailed reasoning, add Risks & Monitoring section, provide explicit testing steps, and include Release Plan with deployment considerations.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: migrating the test framework from Jest to Vitest, which is the primary objective of the PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ahmed-anas/PLAT-350/jest-to-vitest

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
vitest.config.ts (1)

6-10: Scope coverage include to source files only.

The pattern '**/*.[tj]s' will include all .ts and .js files in the project (config files, scripts, etc.), which may inflate or skew coverage reports. Consider limiting to actual source code.

♻️ Proposed fix
     coverage: {
       provider: 'v8',
-      include: ['**/*.[tj]s'],
+      include: ['src/**/*.[tj]s'],
       exclude: ['node_modules', 'dist', 'vitest.config.ts', '.huskyrc.js'],
     },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@vitest.config.ts` around lines 6 - 10, The coverage include pattern in
vitest.config.ts is too broad ('**/*.[tj]s') and should be restricted to your
source files; update the coverage.include entry (coverage.include) to target
only the src tree—e.g. use a pattern like 'src/**/*.{ts,tsx,js,jsx}' or
'src/**/*.[jt]s' so only application source files are measured and
config/scripts are excluded.
test/.eslintrc.json (1)

2-2: Consider adding Vitest-specific ESLint rules.

The change from mixmax/node/jest to mixmax/node removes Jest-specific linting. For feature parity (e.g., catching common Vitest test mistakes), you could add eslint-plugin-vitest. This is optional since the tests will still lint and run correctly without it.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/.eslintrc.json` at line 2, The ESLint config currently replaces
"extends": "mixmax/node" which drops Jest rules; to add Vitest-specific linting
install and enable eslint-plugin-vitest and update the config by adding the
plugin and Vitest recommended rules (for example add "plugins": ["vitest"] and
"extends": ["mixmax/node", "plugin:vitest/recommended"] and/or set "env": {
"vitest/globals": true }) so tests get Vitest-aware rules while keeping
"extends": "mixmax/node".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@test/.eslintrc.json`:
- Line 2: The ESLint config currently replaces "extends": "mixmax/node" which
drops Jest rules; to add Vitest-specific linting install and enable
eslint-plugin-vitest and update the config by adding the plugin and Vitest
recommended rules (for example add "plugins": ["vitest"] and "extends":
["mixmax/node", "plugin:vitest/recommended"] and/or set "env": {
"vitest/globals": true }) so tests get Vitest-aware rules while keeping
"extends": "mixmax/node".

In `@vitest.config.ts`:
- Around line 6-10: The coverage include pattern in vitest.config.ts is too
broad ('**/*.[tj]s') and should be restricted to your source files; update the
coverage.include entry (coverage.include) to target only the src tree—e.g. use a
pattern like 'src/**/*.{ts,tsx,js,jsx}' or 'src/**/*.[jt]s' so only application
source files are measured and config/scripts are excluded.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 251aff39-22fb-4e7e-836f-987e4c5a383d

📥 Commits

Reviewing files that changed from the base of the PR and between 04a47d9 and 880d463.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (5)
  • jest.config.js
  • package.json
  • src/index.test.ts
  • test/.eslintrc.json
  • vitest.config.ts
💤 Files with no reviewable changes (1)
  • jest.config.js

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.

1 participant