Hey folks,
We just open-sourced a library we've been using internally at SEON for Pact.js contract testing, thought it might be useful for others here.
Pact is powerful but the setup boilerplate adds up fast.
Every team ends up writing the same plumbing.
The library extracts those patterns into composable utilities.
What's in it:
- createProviderState / toJsonMap : typed provider state params without the JsonMap conversion headache
- buildVerifierOptions / buildMessageVerifierOptions : one call to build complete VerifierOptions for HTTP and message verification
- createRequestFilter : injects auth headers into verification requests without the Express type gymnastics
- handlePactBrokerUrlAndSelectors : reads env vars and assembles the right consumer version selector strategy automatically
github:
https://github.com/seontechnologies/pactjs-utils
npm:
https://www.npmjs.com/package/@seontechnologies/pactjs-utils
docs:
https://seontechnologies.github.io/pactjs-utils/
The repo also functions as an educational resource, dogfooding the lib, and showcasing vanilla vs lib versions of the same tests.
P.S. For those moving toward agentic QA:
BMad Test Architect now has a pactjs-utils installation option.
It’s designed to create and self-heal contract tests using these patterns out of the box.
https://bmad-code-org.github.io/bmad-method-test-architecture-enterprise/