Skip to content

Migrate from Mocha to Vitest #2789

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

2nofa11
Copy link
Contributor

@2nofa11 2nofa11 commented Jul 12, 2025

Summary

Migrates the test framework from Mocha to Vitest to significantly improve test execution performance.

Closes #2787

Changes Made

060f779 - Initial Migration (Automated)

3b667b0 - Manual Configuration & Integration Fixes

  • Added vitest.config.ts with comprehensive test configuration:
    • Coverage provider set to v8
    • Configured include/exclude patterns
  • Fixed integration tests to address Vitest worker limitations (vitest#1436):
    • Replaced process.chdir() usage with cwd option in cp.execSync() calls
    • Updated tests/integrations/eslint-plugin-import.js
    • Updated tests/integrations/flat-config.js
    • Replaced before/after hooks with beforeAll

ec06a3e - Global API Configuration

  • Updated eslint.config.mjs to use vitest globals instead of mocha

Migration Details

  • Test Coverage: All 11,059 tests pass without modification
  • Compatibility: Maintains ESLint RuleTester compatibility
  • Performance: 67% faster execution (74s → 24s)
  • Configuration: Comprehensive vitest.config.ts with:
    • V8 coverage provider
    • HTML and LCOV reporting
    • Proper include/exclude patterns
    • Global API configuration

Test Plan

  • All existing tests pass (11,059 tests)
  • Integration tests work correctly
  • Coverage reporting functional
  • Performance improvement verified
  • CI/CD pipeline validation needed

Copy link

changeset-bot bot commented Jul 12, 2025

⚠️ No Changeset found

Latest commit: ec06a3e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR


before(() => {
originalCwd = process.cwd()
process.chdir(path.join(__dirname, 'eslint-plugin-import'))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Migrating to Vitest resulted in a Flaky test, because process.chdir() is not supported by Vitest (vitest-dev/vitest#1436).
So I substituted execSync({ cwd }).

@2nofa11 2nofa11 force-pushed the chore/migrate-to-vitest branch from ec06a3e to 97312e7 Compare July 12, 2025 09:30
@2nofa11 2nofa11 marked this pull request as ready for review July 12, 2025 10:51
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.

Migrate to Vitest
1 participant