Skip to content

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
mainfrom
claude/zealous-hawking-02jl7t
Open

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
TimothyJones wants to merge 13 commits into
mainfrom
claude/zealous-hawking-02jl7t

Conversation

@TimothyJones

Copy link
Copy Markdown
Member

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 from contract-case-jest)
  • @contract-case/contract-case-dsl-js-vitest — new Vitest suite

main has been merged in and the conflicts from the package split reconciled.

Merge reconciliation

  • tsconfig.json — adopted main'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 (on contract-case-dsl-js + cli) and integrated main's new NO_INTERACTIONS_DEFINED test.
  • .release-please-manifest.json — updated for the new package set.
  • package-lock.json — regenerated.

Fixes folded in (would otherwise break CI)

  1. Aligned the four new packages and their internal @contract-case/* deps from 0.28.2 to 0.29.1 (a mismatch breaks npm workspace resolution).
  2. Declared the jest specs' spec-only imports (case-plugin-base, case-definition-dsl, case-entities-internal) as devDependencies, so import/no-extraneous-dependencies passes.
  3. Updated the docs footer npm link to the renamed jest package.
  4. Added a .gitignore so the vitest package's generated case-contracts/ aren't tracked.

Verification

format:check, JS build, lint (0 errors), the nx project graph, and the new NO_INTERACTIONS_DEFINED test all pass locally. Socket-bound HTTP tests, the dsl-java Gradle build, and grpc-tools install 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

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
@TimothyJones TimothyJones changed the title feat: split JS packages and add vitest bindings 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 Jun 20, 2026
@@ -1,7 +1,7 @@
{
"name": "@contract-case/contract-case-jest",
"name": "@contract-case/contract-case-dsl-js-jest",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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

claude added 2 commits June 20, 2026 06:53
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
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.

2 participants