feat: Add vitest bindings with the same interface as the jest interface, and extract common code to a shared package, contract-case-dsl-js, useful for anyone building further bindings#1328
Open
TimothyJones wants to merge 13 commits into
Conversation
Extract shared (non-test-framework-specific) code from contract-case-jest into a new contract-case-connector-js package. Both contract-case-jest and the new contract-case-vitest package now depend on the shared connector, keeping only their framework-specific bindings (describe/it/afterAll wrappers). - New package: @contract-case/contract-case-connector-js Contains: ContractDefiner, ContractVerifier, TriggerGroupMap, DSL (Matchers, Interactions, States), entity types, error classes, and boundary mappers - New package: @contract-case/contract-case-vitest Vitest-specific defineContract/verifyContract using vitest's describe/it and vi.setConfig for timeouts - Updated: @contract-case/contract-case-jest Now re-exports from connector-js, keeping only jest-specific bindings https://claude.ai/code/session_015ncC7UbQNQN3st9e3HEBNA
- Extract user-facing code (DSL, classes, types, errors) to new contract-case-dsl-js package - Keep internal code (boundary mappers, printer, handler) in contract-case-connector-js - Rename contract-case-jest to contract-case-dsl-js-jest - Rename contract-case-vitest to contract-case-dsl-js-vitest - Add vitest test files mirroring the jest test suite (define and verify specs for HTTP client/server, function caller/implementer) - Copy test fixtures (client, server, gRPC) to vitest package - Update vitest.config.ts to include .spec.verify.ts files https://claude.ai/code/session_015ncC7UbQNQN3st9e3HEBNA
- Fix import ordering in dsl-js (external imports before local) - Merge duplicate imports from connector-js in ContractDefiner/ContractVerifier - Merge duplicate imports from index.js in jest verify specs - Fix duplicate imports in jest documentation spec - Add missing gRPC devDependencies to vitest package - Apply prettier formatting fixes https://claude.ai/code/session_015ncC7UbQNQN3st9e3HEBNA
- Fix Java test contractDir path to use contract-case-dsl-js-jest - Update release-please manifest and config for renamed/new packages - Regenerate package-lock.json to remove stale entries https://claude.ai/code/session_015ncC7UbQNQN3st9e3HEBNA
Reconcile the JS package split (contract-case-jest -> contract-case-dsl-js, contract-case-dsl-js-jest, contract-case-dsl-js-vitest, and the shared contract-case-connector-js) with main's changes: - Adopt main's project-references root tsconfig.json, updating the references list to the new package layout (drop contract-case-jest, add the four new JS packages). - Place main's new NO_INTERACTIONS_DEFINED test into contract-case-dsl-js-jest and add its spec-only deps (case-plugin-base, case-definition-dsl, case-entities-internal). - Align the four new packages and their internal deps to 0.29.1. - Update .release-please-manifest.json for the new package layout. - Regenerate package-lock.json. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8keRP4HqZBnfUcw9Zz1ZA
The contract-case-jest package was renamed to contract-case-dsl-js-jest; point the documentation footer's npm link at the new package name. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8keRP4HqZBnfUcw9Zz1ZA
The vitest DSL package generates contract files under case-contracts/ when its define specs run, but (unlike the jest package) it has no verify step that consumes committed contracts, so these are pure test artifacts and should not be tracked. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8keRP4HqZBnfUcw9Zz1ZA
…g-02jl7t # Conflicts: # package-lock.json # packages/contract-case-dsl-js-jest/case-contracts/http-request-provider/http-request-consumer-8e6213abbb7cfc5460d338b160a62fbfcd17c09bdc0eb7b996485ee683132ef4.case.json # packages/contract-case-dsl-js-jest/case-contracts/http-response-provider/http-response-consumer-7b2e98081dfaa95cf7b8372e3d65d7ebff084bcf83a6c31eb47dfffaaf766b12.case.json # packages/contract-case-jest/dist/bin/ContractCase.mjs
The previous from-scratch lockfile regeneration was run on Linux and dropped platform-specific optional dependencies (darwin/win32 binaries for nx, esbuild, rollup, unrs-resolver), which broke `npm install` on macOS and Windows CI runners. Regenerate the lockfile incrementally from main so all platform variants are preserved, and add an override forcing tmp@^0.2.7 to resolve the high-severity advisory GHSA-7c78-jf6q-g5cm (tmp path traversal) that dependency-review flagged on the transitive tmp@0.2.6 pulled in by nx. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8keRP4HqZBnfUcw9Zz1ZA
The vitest package's `vitest run` executes both the define specs (in maintainer snapshot mode, changedContracts=FAIL) and the verify specs, both of which require committed baseline contracts under case-contracts/ - exactly as the jest package commits its own baselines. These were never committed, so test:local failed on socket-capable CI runners with "changedContracts set to fail" and "directory 'case-contracts' does not exist". Generate and commit the baselines (the function contracts are byte-identical to the jest package's committed contracts, confirming deterministic output), and drop the earlier .gitignore that incorrectly excluded them. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8keRP4HqZBnfUcw9Zz1ZA
contract-case-dsl-js, useful for anyone building further bindings
TimothyJones
commented
Jun 20, 2026
| @@ -1,7 +1,7 @@ | |||
| { | |||
| "name": "@contract-case/contract-case-jest", | |||
| "name": "@contract-case/contract-case-dsl-js-jest", | |||
Member
Author
There was a problem hiding this comment.
@claude Let's not rename this package, as it would be a breaking change for consumers. Let's keep it as @contract-case/contract-case-jest for npm
Member
Author
There was a problem hiding this comment.
Done in bb7d7e2 — reverted the npm name back to @contract-case/contract-case-jest so it's not a breaking change for consumers. The directory stays packages/contract-case-dsl-js-jest, but the published package name is unchanged. Also updated the release-please component, the doc-example imports, and the npm download link to match.
Generated by Claude Code
Rename the internal package @contract-case/contract-case-connector-js to @contract-case/contract-case-dsl-js-internals (directory included). The old name was confusing because it sits in front of the main case-connector, which is also JS; "dsl-js-internals" makes its role clearer. Updates the package name, the dsl-js dependency and imports, error-source location tags, the root tsconfig project reference, and the release-please config/manifest. Also revert the Jest package's npm name back to @contract-case/contract-case-jest (the directory stays contract-case-dsl-js-jest) so the published package name does not change - renaming it would be a breaking change for existing consumers. Updates the package name, documentation example imports, the docs download link, and the release-please component. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8keRP4HqZBnfUcw9Zz1ZA
Now that the Vitest bindings (@contract-case/contract-case-dsl-js-vitest) are available, present Vitest as a supported JS/TS test runner in the docs: - Getting started install snippet now offers a Jest/Vitest tab choice. - Add Vitest example links and fix the Jest example links to the renamed package directory. - Update the README compatibility note and the defining-contracts DSL comment to mention both Jest and Vitest. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8keRP4HqZBnfUcw9Zz1ZA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Splits the JavaScript bindings into focused packages and adds Vitest support:
@contract-case/contract-case-connector-js— shared internal JS/TS connector code@contract-case/contract-case-dsl-js— user-facing DSL@contract-case/contract-case-dsl-js-jest— Jest suite (renamed fromcontract-case-jest)@contract-case/contract-case-dsl-js-vitest— new Vitest suitemainhas been merged in and the conflicts from the package split reconciled.Merge reconciliation
tsconfig.json— adoptedmain's project-references root config, updating the references list to the new package layout.contract-case-dsl-js-jest/package.json— kept the thin-wrapper dependency structure (oncontract-case-dsl-js+cli) and integratedmain's newNO_INTERACTIONS_DEFINEDtest..release-please-manifest.json— updated for the new package set.package-lock.json— regenerated.Fixes folded in (would otherwise break CI)
@contract-case/*deps from0.28.2to0.29.1(a mismatch breaks npm workspace resolution).case-plugin-base,case-definition-dsl,case-entities-internal) as devDependencies, soimport/no-extraneous-dependenciespasses..gitignoreso the vitest package's generatedcase-contracts/aren't tracked.Verification
format:check, JSbuild,lint(0 errors), the nx project graph, and the newNO_INTERACTIONS_DEFINEDtest all pass locally. Socket-bound HTTP tests, thedsl-javaGradle build, andgrpc-toolsinstall couldn't run in the dev sandbox (no IPv6 sockets / Java 17 toolchain / binary download), but those are environment limitations and are exercised here in CI.🤖 Generated with Claude Code
Generated by Claude Code