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 8 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: 85cfbea

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

@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
Copy link
Member

@FloEdelmann FloEdelmann left a comment

Choose a reason for hiding this comment

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

While searching for mocha in the repo (https://github.com/search?q=repo%3Avuejs%2Feslint-plugin-vue%20mocha&type=code), I found two more occurrences that should probably be adapted, or just removed:

  • tests/.eslintrc.json
  • .vscode/launch.json

Copy link
Member

@FloEdelmann FloEdelmann left a comment

Choose a reason for hiding this comment

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

Looks good to me 🙂
Thank you! 🚀

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Migrates the test framework from Mocha to Vitest to improve test execution performance and update related configurations.

  • Added a vitest.config.ts with test and coverage settings
  • Updated integration tests to use Vitest-compatible hooks and cwd options instead of process.chdir()
  • Swapped out Mocha scripts, dependencies, and ESLint globals for Vitest equivalents; removed old VSCode launch config

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
vitest.config.ts Introduce Vitest test and coverage configuration
tests/integrations/flat-config.js Use beforeAll and cwd option for flat-config integration test
tests/integrations/eslint-plugin-import.js Use beforeAll and cwd option for plugin-import integration test
tests/.eslintrc.json Remove Mocha-specific ESLint config
package.json Update scripts and dependencies from Mocha/nyc to Vitest
eslint.config.mjs Switch ESLint globals from Mocha to Vitest
.vscode/launch.json Remove outdated Mocha debug configuration
Comments suppressed due to low confidence (1)

@2nofa11
Copy link
Contributor Author

2nofa11 commented Jul 17, 2025

@waynzh @FloEdelmann
Thank you for reviewing my PR 🚀
Your review helped me to create a better one 💯

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
3 participants