Skip to content

test: migrate from jest to vitest 3.1.4 #261

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

Merged

Conversation

MikeMcC399
Copy link
Collaborator

@MikeMcC399 MikeMcC399 commented May 29, 2025

Situation

  • Repo tests (npm test) are run with Jest

  • Installing [email protected] or the following beta version [email protected] shows deprecations, and given that these are unaddressed issues https://github.com/jestjs/jest/issues it seems unlikely that they will be resolved in the immediate future:

    npm warn deprecated [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
    npm warn deprecated [email protected]: Glob versions prior to v9 are no longer supported

  • The last Jest blog post was announcing the current version Jest 29 in Aug 2022

  • Vitest is a well-maintained testing framework that has many similarities to Jest. Its documentation explains specifically about Migrating from Jest.

Change

  • Migrate from Jest to [email protected]

  • Simplify scripts to define and use only npm test in vitest run mode. Remove start script to run Jest in watch mode.

  • Replace jest.config.js with vitest.config.mts

  • Update CONTRIBUTING document accordingly

Verification

On Ubuntu 24.04.2 LTS, Node.js 22.16.0 LTS

Execute the following and confirm that all tests run without errors:

npm ci
npm run lint
npm run test

@cypress-app-bot
Copy link

@MikeMcC399 MikeMcC399 self-assigned this May 29, 2025
@MikeMcC399 MikeMcC399 marked this pull request as ready for review May 29, 2025 16:02
Copy link
Member

@jennifer-shehane jennifer-shehane left a comment

Choose a reason for hiding this comment

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

Nice! Simpler than I thought. Jest vs Vitest - looks to be running all the tests.

Screenshot 2025-05-29 at 12 25 49 PM

Screenshot 2025-05-29 at 12 26 08 PM

@jennifer-shehane jennifer-shehane merged commit 2412c29 into cypress-io:master May 29, 2025
12 checks passed
@MikeMcC399
Copy link
Collaborator Author

@jennifer-shehane

Nice! Simpler than I thought. Jest vs Vitest - looks to be running all the tests.

The migration was simpler than I thought as well. I just wanted to wait until we had got rid of the legacy configs, otherwise it would have been a bit more complicated.

@MikeMcC399 MikeMcC399 deleted the migrate/jest-to-vitest branch May 29, 2025 16:43
@jennifer-shehane
Copy link
Member

🎉 This PR is included in version 5.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate away from Jest v29
3 participants