Hi, Can we use pact for integration tests with moc...
# general
s
Hi, Can we use pact for integration tests with mocking rather using mock-server ?
m
With Pact, you must use the mock server. It’s an important part of how the framework captures the contract.
If you want a slightly more decoupled approach, you can consider something like our BDCT approach: https://docs.pactflow.io/docs/bi-directional-contract-testing There are differences in the value/guarantees they provide, the link above discusses some of these trade offs.
s
@Matt (pactflow.io / pact-js / pact-go) actually i am looking for some alternatives for mock-server
m
What's your goal?
s
Remove the dependencies and mock the response
m
That's what Pact does.
If you want to use your own mocks, that's where bidirectional comes in. You can use your own locking tools and convert to a consumer contract
s
I never used Pact but is it ok to do this with Pact as well, right ?
Cause its not a contract testing to be honest its more integration test
m
No, you must use the mocker server with pact to generate a contract. Once you've done that we can provide a stub server you can use to remove dependencies
It's not a general purpose mocking tool
s
So should I use mock-server in any case ?
m
Just so I'm clear, what exactly are you proposing
s
Mocking response and isolate service from other dependencies
m
Ok. Will you be using one of the pact languages?
s
You mean smth like pact-js ?
m
Yeah
s
yeap..
👍 1
When I check this documentation seems mock server is possible but I guess I need to use stub server as well https://github.com/pact-foundation/pact-js
So the things confused me do I still need to use mock-server(https://www.mock-server.com/) or can I achive samething with pact
m
Once you've created a pact you can use the stub server a bit like mock-server.com. but it's not a general purpose mocking tool, so you'll need to see how far it gets you
Remember it's goal is creating contracts, and ensuring your mocks don't drift from reality
s
Is delays, erroneous situations etc possible with Pact?
m
No non functional tests like delays, but 4xx and 5xx yes
👍 1