Skip to content
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

Migrate from jest to vitest + msw (pactjs-cli) #1024

Merged
merged 3 commits into from
Oct 18, 2023

Conversation

webpro
Copy link
Contributor

@webpro webpro commented Oct 10, 2023

Here's the first migration from Jest to Vitest + MSW. My plan is to go through all packages and wrap up with some shared helpers or config where it makes sense.

I believe this one is great for starters as it not only introduces Vitest, but also MSW. This combo really lifts our tests to the next level. For instance, no more fiddling to get mocks right, but intercepting requests at the lowest possible level. So it doesn't matter what lib we are using to do requests.

Speed is also a major win. Vitest is consistently at least 50-75% faster and I predict this difference will only get larger when the projects/tests grow.

Jest:

 PASS  src/utils/tests/callLocal.test.ts
 PASS  src/utils/tests/retrieveContractFromChain.test.ts
 PASS  src/retrieve-contract/tests/retrieve-contract.test.ts
Test Suites: 4 passed, 4 total
Tests:       6 passed, 6 total
Snapshots:   0 total
Time:        1.271s

Vitest:

 ✓ src/retrieve-contract/tests/retrieve-contract.test.ts (2)
 ✓ src/utils/tests/callLocal.test.ts (2)
 ✓ src/utils/tests/retrieveContractFromChain.test.ts (1)

 Test Files  3 passed (3)
      Tests  5 passed (5)
   Start at  06:37:18
   Duration  311ms (transform 69ms, setup 0ms, collect 318ms, tests 99ms, environment 0ms, prepare 146ms)

@changeset-bot
Copy link

changeset-bot bot commented Oct 10, 2023

🦋 Changeset detected

Latest commit: afb3a06

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

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

Not sure what this means? Click here to learn what changesets are.

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

@vercel
Copy link

vercel bot commented Oct 10, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

5 Ignored Deployments
Name Status Preview Comments Updated (UTC)
alpha-docs ⬜️ Ignored (Inspect) Visit Preview Oct 18, 2023 11:29am
docs-storybook ⬜️ Ignored (Inspect) Visit Preview Oct 18, 2023 11:29am
immutable-records ⬜️ Ignored (Inspect) Visit Preview Oct 18, 2023 11:29am
react-ui ⬜️ Ignored (Inspect) Visit Preview Oct 18, 2023 11:29am
tools ⬜️ Ignored (Inspect) Visit Preview Oct 18, 2023 11:29am

@webpro webpro marked this pull request as ready for review October 11, 2023 04:45
@webpro webpro requested a review from alber70g as a code owner October 11, 2023 04:45
@webpro webpro force-pushed the chore/migrate-from-jest-to-vitest-1 branch from d682880 to afb3a06 Compare October 18, 2023 11:20
@webpro webpro merged commit 70bf2fb into main Oct 18, 2023
5 of 6 checks passed
@webpro webpro deleted the chore/migrate-from-jest-to-vitest-1 branch October 18, 2023 11:29
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.

5 participants