# Behavior traces — pact-foundation/pact-js

> Canonical page: https://codevetter.com/unpack/pact-js/behavior-traces

# Behavior traces — pact-foundation/pact-js

Scanned commit 18f30a1aa44a948b3249a72879da3cff26c42d12 (2026-10-02). Generated by codevetter codevetter 1.15.0 on 2026-10-02.

Source inspection; upstream code and tests were not executed.

Three concrete flows were followed through source: V4 HTTP consumer testing, HTTP provider verification, and V4 asynchronous message testing. Each trace follows declaration, execution, and persistence or result handling. The examples show application clients and handlers participating in those flows rather than treating the library's builders as the entire test.
- HTTP consumer startup: new Pact constructs PactV4 → setup → makeConsumerPact with default V4 → addMetadata; addInteraction then creates a native interaction and an UnconfiguredInteraction carrying a parent-reset callback. — [src/v4/index.ts#L19-L47](https://github.com/pact-foundation/pact-js/blob/18f30a1aa44a948b3249a72879da3cff26c42d12/src/v4/index.ts#L19-L47) [src/v4/index.ts#L95-L98](https://github.com/pact-foundation/pact-js/blob/18f30a1aa44a948b3249a72879da3cff26c42d12/src/v4/index.ts#L95-L98) [examples/http/consumer.test.ts#L24-L35](https://github.com/pact-foundation/pact-js/blob/18f30a1aa44a948b3249a72879da3cff26c42d12/examples/http/consumer.test.ts#L24-L35)
- HTTP declaration: given/uponReceiving configure native state and description → withRequest configures method/path and runs RequestBuilder → willRespondWith sets status and runs ResponseBuilder → returns InteractionWithResponse. — [src/v4/http/unconfiguredInteraction.ts#L33-L46](https://github.com/pact-foundation/pact-js/blob/18f30a1aa44a948b3249a72879da3cff26c42d12/src/v4/http/unconfiguredInteraction.ts#L33-L46) [src/v4/http/unconfiguredInteraction.ts#L86-L101](https://github.com/pact-foundation/pact-js/blob/18f30a1aa44a948b3249a72879da3cff26c42d12/src/v4/http/unconfiguredInteraction.ts#L86-L101) [src/v4/http/interactionWithRequest.ts#L26-L42](https://github.com/pact-foundation/pact-js/blob/18f30a1aa44a948b3249a72879da3cff26c42d12/src/v4/http/interactionWithRequest.ts#L26-L42) [examples/http/consumer.test.ts#L44-L63](https://github.com/pact-foundation/pact-js/blob/18f30a1aa44a948b3249a72879da3cff26c42d12/examples/http/consumer.test.ts#L44-L63)
- HTTP execution: InteractionWithResponse.executeTest → shared executeTest → native transport mock startup → UserServiceClient.getUser sends Axios GET → callback assertions → mismatch checks → writePactFile/cleanup/reset; callback errors are rethrown and failure branches skip writing. — [src/v4/http/interactionWithResponse.ts#L17-L18](https://github.com/pact-foundation/pact-js/blob/18f30a1aa44a948b3249a72879da3cff26c42d12/src/v4/http/interactionWithResponse.ts#L17-L18) [src/v4/http/index.ts#L40-L104](https://github.com/pact-foundation/pact-js/blob/18f30a1aa44a948b3249a72879da3cff26c42d12/src/v4/http/index.ts#L40-L104) [examples/http/consumer.ts#L31-L36](https://github.com/pact-foundation/pact-js/blob/18f30a1aa44a948b3249a72879da3cff26c42d12/examples/http/consumer.ts#L31-L36) [examples/http/consumer.test.ts#L64-L74](https://github.com/pact-foundation/pact-js/blob/18f30a1aa44a948b3249a72879da3cff26c42d12/examples/http/consumer.test.ts#L64-L74)
- Provider startup: the example starts createApp on port 3001 → constructs Verifier with the generated pact path and state handlers → verifyProvider creates hooks state and proxy → waitForServerReady → runProviderVerification → verifyPacts. — [examples/http/provider.test.ts#L19-L48](https://github.com/pact-foundation/pact-js/blob/18f30a1aa44a948b3249a72879da3cff26c42d12/examples/http/provider.test.ts#L19-L48) [src/dsl/verifier/verifier.ts#L92-L112](https://github.com/pact-foundation/pact-js/blob/18f30a1aa44a948b3249a72879da3cff26c42d12/src/dsl/verifier/verifier.ts#L92-L112) [src/dsl/verifier/verifier.ts#L132-L149](https://github.com/pact-foundation/pact-js/blob/18f30a1aa44a948b3249a72879da3cff26c42d12/src/dsl/verifier/verifier.ts#L132-L149)
- Provider state and request replay: /_pactSetup runs hook middleware before requestFilter and state dispatch → setupStates invokes the named callback → clearUsers/seedUser populate the example Map → other requests reach proxy.web → createApp returns /users or /users/:id JSON. — [src/dsl/verifier/proxy/proxy.ts#L47-L84](https://github.com/pact-foundation/pact-js/blob/18f30a1aa44a948b3249a72879da3cff26c42d12/src/dsl/verifier/proxy/proxy.ts#L47-L84) [src/dsl/verifier/proxy/stateHandler/setupStates.ts#L27-L49](https://github.com/pact-foundation/pact-js/blob/18f30a1aa44a948b3249a72879da3cff26c42d12/src/dsl/verifier/proxy/stateHandler/setupStates.ts#L27-L49) [examples/http/provider.test.ts#L36-L45](https://github.com/pact-foundation/pact-js/blob/18f30a1aa44a948b3249a72879da3cff26c42d12/examples/http/provider.test.ts#L36-L45) [examples/http/provider.ts#L17-L44](https://github.com/pact-foundation/pact-js/blob/18f30a1aa44a948b3249a72879da3cff26c42d12/examples/http/provider.ts#L17-L44)
- Provider completion: registerHooks records hook exceptions while continuing middleware; after verifyPacts resolves, verifyProvider closes the server and rejects recorded hook errors, and its catch branch also closes the server before rethrowing. — [src/dsl/verifier/proxy/hooks.ts#L34-L48](https://github.com/pact-foundation/pact-js/blob/18f30a1aa44a948b3249a72879da3cff26c42d12/src/dsl/verifier/proxy/hooks.ts#L34-L48) [src/dsl/verifier/proxy/hooks.ts#L57-L75](https://github.com/pact-foundation/pact-js/blob/18f30a1aa44a948b3249a72879da3cff26c42d12/src/dsl/verifier/proxy/hooks.ts#L57-L75) [src/dsl/verifier/verifier.ts#L113-L129](https://github.com/pact-foundation/pact-js/blob/18f30a1aa44a948b3249a72879da3cff26c42d12/src/dsl/verifier/verifier.ts#L113-L129)
- Async message declaration: PactV4.addAsynchronousInteraction → newAsynchronousMessage → given → expectsToReceive → AsynchronousMessageBuilder.withJSONContent/withMetadata; the OrderPlaced example supplies matching declarations and queue metadata. — [src/v4/index.ts#L66-L77](https://github.com/pact-foundation/pact-js/blob/18f30a1aa44a948b3249a72879da3cff26c42d12/src/v4/index.ts#L66-L77) [src/v4/message/asynchronousMessage.ts#L75-L104](https://github.com/pact-foundation/pact-js/blob/18f30a1aa44a948b3249a72879da3cff26c42d12/src/v4/message/asynchronousMessage.ts#L75-L104) [src/v4/message/asynchronousMessage.ts#L201-L233](https://github.com/pact-foundation/pact-js/blob/18f30a1aa44a948b3249a72879da3cff26c42d12/src/v4/message/asynchronousMessage.ts#L201-L233) [examples/messages/consumer.test.ts#L36-L62](https://github.com/pact-foundation/pact-js/blob/18f30a1aa44a948b3249a72879da3cff26c42d12/examples/messages/consumer.test.ts#L36-L62)
- Async execution and persistence: AsynchronousMessageWithContent.executeTest → executeNonTransportTest → reifyMessage/JSON.parse → v4SynchronousBodyHandler extracts contents.content → application handler; callback failure cleans without writing, while success writes ./pacts or opts.dir, cleans plugins, and resets. — [src/v4/message/asynchronousMessage.ts#L255-L264](https://github.com/pact-foundation/pact-js/blob/18f30a1aa44a948b3249a72879da3cff26c42d12/src/v4/message/asynchronousMessage.ts#L255-L264) [src/v4/message/asynchronousMessage.ts#L382-L443](https://github.com/pact-foundation/pact-js/blob/18f30a1aa44a948b3249a72879da3cff26c42d12/src/v4/message/asynchronousMessage.ts#L382-L443) [src/v4/message/index.ts#L494-L507](https://github.com/pact-foundation/pact-js/blob/18f30a1aa44a948b3249a72879da3cff26c42d12/src/v4/message/index.ts#L494-L507) [examples/messages/consumer.test.ts#L64-L70](https://github.com/pact-foundation/pact-js/blob/18f30a1aa44a948b3249a72879da3cff26c42d12/examples/messages/consumer.test.ts#L64-L70)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
