Skip to content

chore: migrate to vitest#1789

Merged
JP-Ellis merged 6 commits intomasterfrom
chore/migrate-to-vitest
May 6, 2026
Merged

chore: migrate to vitest#1789
JP-Ellis merged 6 commits intomasterfrom
chore/migrate-to-vitest

Conversation

@JP-Ellis
Copy link
Copy Markdown
Contributor

@JP-Ellis JP-Ellis commented May 6, 2026

Replace mocha with vitest for faster test running, and native TS support. Also reduce the number of dependencies by switching to vitest's own assertion library.

@JP-Ellis
Copy link
Copy Markdown
Contributor Author

JP-Ellis commented May 6, 2026

PS: Aware of the CI failure, will follow up (just getting it out first for visibility)

@JP-Ellis JP-Ellis marked this pull request as draft May 6, 2026 04:18
Copy link
Copy Markdown

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

This PR migrates the project’s test runner from Mocha/Chai/Sinon + NYC to Vitest, aiming for faster test execution, simpler dependencies, and built-in coverage via V8.

Changes:

  • Add Vitest configuration (globals, timeouts, coverage settings) and switch npm test / npm run coverage to Vitest.
  • Update unit/integration tests to use Vitest/Jest-style matchers and vi mocks instead of Chai/Sinon.
  • Remove Mocha/NYC configuration files and update some regression/example package lockfiles accordingly.

Reviewed changes

Copilot reviewed 32 out of 44 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
vitest.config.ts Introduces Vitest runner + coverage configuration.
src/xml/xmlElement.spec.ts Replaces Chai assertions with Vitest matchers.
src/v4/http/responseWithPluginBuilder.spec.ts Replaces Sinon stubs with vi.fn() and Vitest mock assertions.
src/v4/http/responseBuilder.spec.ts Migrates builder tests to vi mocks + Vitest assertions.
src/v4/http/requestWithPluginBuilder.spec.ts Migrates request plugin builder tests to Vitest.
src/v4/http/requestBuilder.spec.ts Migrates request builder tests to Vitest.
src/v4/http/index.spec.ts Migrates V4 HTTP executeTest specs; switches stubs to vi.fn().
src/v3/pact.spec.ts Migrates PactV3 executeTest specs to Vitest mocks/assertions.
src/v3/matchers.spec.ts Migrates matcher specs to Vitest toEqual/toThrow assertions.
src/v3/ffi.spec.ts Migrates FFI spec assertions to Vitest matchers.
src/pact.integration.spec.ts Migrates integration spec assertions away from Chai.
src/messageProviderPact.spec.ts Migrates MessageProvider tests from chai-as-promised to async/await + Vitest assertions.
src/messageConsumerPact.spec.ts Migrates MessageConsumer tests to async/await + Vitest assertions.
src/httpPact/index.spec.ts Migrates HTTP Pact tests to Vitest and vi.fn() call assertions.
src/httpPact/ffi.spec.ts Migrates HTTP FFI tests to Vitest and vi.fn() call assertions.
src/dsl/verifier/verifier.spec.ts Replaces proxyquire/sinon with vi.mock and vi.spyOn patterns.
src/dsl/verifier/proxy/stateHandler/stateHandler.spec.ts Migrates state handler proxy tests to Vitest spies/assertions.
src/dsl/verifier/proxy/stateHandler/setupStates.spec.ts Migrates setupStates tests to Vitest spies/assertions.
src/dsl/verifier/proxy/proxyRequest.spec.ts Migrates proxy request tests to Vitest matchers.
src/dsl/verifier/proxy/proxy.spec.ts Migrates waitForServerReady tests to async/await + Vitest assertions.
src/dsl/verifier/proxy/parseBody.spec.ts Migrates parseBody tests to Vitest matchers.
src/dsl/verifier/proxy/hooks.spec.ts Migrates hook tests from sinon stubs to vi.fn() and Vitest assertions.
src/dsl/matchers.spec.ts Migrates DSL matcher tests from Chai to Vitest matchers.
src/dsl/interaction.spec.ts Migrates interaction tests to Vitest matchers and removes chai-as-promised.
src/dsl/graphql.spec.ts Migrates GraphQL interaction tests to Vitest assertions.
src/dsl/apolloGraphql.spec.ts Migrates Apollo GraphQL interaction tests to Vitest assertions.
src/common/request.spec.ts Migrates request tests to async/await and Vitest assertions.
src/common/net.spec.ts Migrates network/port availability tests to async/await and Vitest assertions.
package.json Switches scripts/deps from Mocha/NYC to Vitest + V8 coverage.
regression/v2/serverless/package.json Updates the local file dependency path for @pact-foundation/pact.
regression/v2/serverless/package-lock.json Lockfile updates reflecting dependency + toolchain changes.
examples/messages/package-lock.json Lockfile updates reflecting Vitest toolchain changes.
.nycrc Removes NYC configuration (coverage handled by Vitest).
.mocharc.json Removes Mocha configuration (runner replaced by Vitest).
Files not reviewed (1)
  • regression/v2/serverless/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/dsl/verifier/verifier.spec.ts Outdated
Comment thread regression/v2/serverless/package.json
Comment thread package.json Outdated
Comment thread src/dsl/verifier/verifier.spec.ts
@JP-Ellis JP-Ellis force-pushed the chore/migrate-to-vitest branch 4 times, most recently from cd901a5 to c94b556 Compare May 6, 2026 05:33
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 6, 2026

Codecov Report

❌ Patch coverage is 86.31579% with 13 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (master@68155a7). Learn more about missing BASE report.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/index.ts 0.00% 13 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1789   +/-   ##
=========================================
  Coverage          ?   60.60%           
=========================================
  Files             ?       67           
  Lines             ?     4132           
  Branches          ?      350           
=========================================
  Hits              ?     2504           
  Misses            ?     1626           
  Partials          ?        2           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JP-Ellis JP-Ellis force-pushed the chore/migrate-to-vitest branch 3 times, most recently from bb26941 to 8a2cff3 Compare May 6, 2026 06:38
JP-Ellis added 3 commits May 6, 2026 16:55
Replace mocha with vitest for faster test running, and native TS
support. Also reduce the number of dependencies by switching to vitest's
own assertion library.

Signed-off-by: JP-Ellis <josh@jpellis.me>
Signed-off-by: JP-Ellis <josh@jpellis.me>
Not sure why this wasn't covered in CI before

Signed-off-by: JP-Ellis <josh@jpellis.me>
@JP-Ellis JP-Ellis force-pushed the chore/migrate-to-vitest branch from 8a2cff3 to 88bb951 Compare May 6, 2026 06:56
JP-Ellis added 3 commits May 6, 2026 18:41
In particular, consolidate the x86 and ARM tests into one job now that
we have ARM runners available.

Signed-off-by: JP-Ellis <josh@jpellis.me>
Helps with cross-platform support, in case `bash` is not available or
easily invoked (e.g., CI in Windows running in pwsh).

Signed-off-by: JP-Ellis <josh@jpellis.me>
Signed-off-by: JP-Ellis <josh@jpellis.me>
@JP-Ellis JP-Ellis force-pushed the chore/migrate-to-vitest branch from f5c137e to 0152e4e Compare May 6, 2026 08:41
@JP-Ellis JP-Ellis marked this pull request as ready for review May 6, 2026 08:45
@JP-Ellis JP-Ellis merged commit 9d52f44 into master May 6, 2026
44 of 46 checks passed
@JP-Ellis JP-Ellis deleted the chore/migrate-to-vitest branch May 6, 2026 08:48
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.

3 participants