ProviderStates in Pact

143 views Asked by At

From what I can tell, version 3 of the Pact spec says interactions support multiple providerStates and allows you to define parameters. I don't see this supported in the pact-web or pact-js repos. I'm using pact-web and integrating it into an existing Angular project. I ended up adding providerStates by creating a new Interaction class that extends the one defined in the library. Debugging through the app, I see it's serialized and posted to the mock service.

However, I don't see the providerStates property saved to the pact file. I only see providerState. I'm trying to debug through the pact-node project but can't find where the file is actually written to disk. Any advice?

1

There are 1 answers

0
Matthew Fellows On

The current stable Pact JS package does not support V3, but there is a beta package that does.

Pact Web is currently not included in this release and its future is currently uncertain. My recommendation is to write pact tests separate from your Angular test suite (i.e. not in Karma) using Node.js frameworks such as Jest, Mocha etc., or stick with the current beta package without requiring multiple provider states.