Can we run tests on live sites and generate pacts?
# pact-js
s
Can we run tests on live sites and generate pacts?
m
No, sorry. It’s a unit testing tool and just doesn’t work that way
s
Will it run on staging or test environment without mocking
y
You could record fixtures of your provider api that your live site is using with nock https://github.com/nock/nock#recording or similar and use these for testing at your unit test level, and convert these into pact files, see an example here https://docs.pactflow.io/docs/examples/bi-directional/consumer/recordreplay/#steps However as Matt said, Pact is traditionally run at a unit testing level https://docs.pact.io/getting_started/how_pact_works#consumer-testing What is it you are trying to achieve? Recording the traffic will give you the whole response payload so you won't get insight into what your consumer uses, just that they issue a call to x endpoint with y payload. We would always advise using Pact as a 'unit test' or component integration test, for your client class https://docs.pact.io/5-minute-getting-started-guide#scope-of-a-consumer-pact-test Whilst you can generate the pact file format in a multitude of ways (its just a json file adhering to a schema), the type of recording you are looking at might be better suited to capturing interactions into an OpenAPI file for example https://swagger.io/tools/swagger-inspector/
👍 2