Join Slack
Powered by
Can we run tests on live sites and generate pacts?
# pact-js
s
sasank kumar
11/23/2022, 10:47 AM
Can we run tests on live sites and generate pacts?
m
Matt (pactflow.io / pact-js / pact-go)
11/23/2022, 10:57 AM
No, sorry. It’s a unit testing tool and just doesn’t work that way
s
sasank kumar
11/23/2022, 10:59 AM
Will it run on staging or test environment without mocking
y
Yousaf Nabi (pactflow.io)
11/23/2022, 1:33 PM
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
2
Views
Open in Slack
Previous
Next