Repository navigation
Conversation
Spiking #435. A resolver can hand a matcher template to the adapter, the app gets the reified example body, and the pact gets v2 matchingRules. msw doesn't keep Response identity between the resolver and response:mocked (node or browser), and in the browser the Request is re-deserialised too, so templates are keyed on requestId instead. The registry lives on globalThis under a Symbol.for key. In Cypress the handler runs in the app window and the adapter in the spec window, so there you pass templateRegistry: getPactTemplateRegistry(win). Only like/eachLike for now, probe files are throwaway.
…ction Adds packages/pact-matchers, a TS port of the pact-js MatchersV3 DSL and the pact_ffi bodies.rs/pact_models logic that turns a matcher template into a plain body, matching rules (v2 + v3) and generators. Golden tests run every template through the real FFI via pact-js and assert body/rules/generators line up, plus DSL parity with MatchersV3. We follow libpact_ffi 0.5.13 for rules nested under eachValue (pact-reference 1f1c2e61), which the FFI bundled with pact-js 17.1.4 predates. The pactBody spike now sources its DSL and rule generation from the package.
Every golden case is now also run through pact-schemas (v2/v3/v4) with ajv. pact-schemas isn't on npm yet, so point PACT_SCHEMAS_DIR at a checkout's dist/ (or install it from git). The schema checks are skipped without it. Cases where the FFI writes rules its spec version doesn't define are tracked in ffiSpecLeaks. If one of them starts producing a valid pact, the test fails and tells you to drop it from the list. Adds a v4 pass through PactV4.
The FFI writes equality and include into v2 pacts as-is today, so both cases are tracked in ffiSpecLeaks. With the v2 downgrade in pact-foundation/pact-reference#613: - equalityInclude flips: top-level equality is dropped and include becomes a regex. The test will then ask for it to come out of ffiSpecLeaks, and toV2MatchingRules needs to do the same downgrade - equalityUnderParent stays a leak: equality under eachLike has no lossless v2 form, so the FFI keeps it and warns
This branch has not been deployed
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.
Spike, not for merging yet.
spike: pactJson/withPactbuilds matcher templates from msw resolverspackages/pact-matchersis a zero-dep matcher DSL. It extracts rules the same way pact_ffi does, and golden tests compare its output with what pact-js / pact_ffi write for V2/V3/V4Schema validation
Wired pact-schemas into the
golden tests, so every pact the FFI writes for us is also validated
against the spec.
mainThe v4 failures on
mainare schema bugs (eachKey/eachValue rules,arrayContains variants, statusCode classes, generator expressions,
optional contentTypeHint, plugin matchers). They're fixed in the PR above.
v2/v3 also turned up the FFI writing rules a spec version doesn't define
(v4 matchers in v3 pacts,
integerin v2). Those cases are listed inffiSpecLeaksfor now. pact-foundation/pact-reference#613 warns on these,or errors with
PACT_STRICT_SPEC_VERSION=true. I've checked it againstthis harness by swapping the built
libpact_ffiinto pact-js-core'sprebuilds: no change by default, and exactly those 5 cases fail in strict
mode.
To run with the schemas: