marked this post as
Closing down this feature request, as we have released https://www.npmjs.com/package/@pactflow/pact-cypress-adapter to support testing Cypress with Pactflow's bi-directional contract testing feature.
For those of you wanting to integration Cypress with pure Pact testing (not with Pactflow's BDC feature), you can read this answer on SO of how we suggest you achieve it, based on our own experiences running it for ~1 year: https://stackoverflow.com/a/68492932
Thanks for testing out the approach e2e with cypress. Matt Fellows I was wondering about the plugin, do you have any planned release date for cypress plugin?
I know the team is working hard on this but any updates the plugin Matt?
Evan: Thanks Evan! It's still maybe a month or 2 away given our other commitments. We're currently using it over at Pactflow to extract learnings, and after that bedding in period we'll release what we have. If you want to get going now, I'd take what's in https://github.com/pactflow/example-consumer-cypress and port to the plugin when it arrives.
IMHO the problem with UI driven contract testing is the same as with any UI testing: having flaky tests. If Cypress lives up to the promise of being very stable at test execution then it could be a perfect match with Pact. One big advantage is that we do not depend on any test data being available or not. So please publish the plugin :) Could you consider doing the plugin in TypeScript? I would say it is way more future proof.
Gyula Varga: It would be written in TypeScript, as that's pretty much the recommended path anyway. Thanks for the feedback!
Example app available at https://github.com/pactflow/example-consumer-cypress. Will publish as a separate plugin soon.
Here is a video https://youtu.be/jTuuYMFJBBQ that shows:
- First run navigates to /which calls out to an Product listing API/products
- Second run extends the test to click through to a product page which needs to hit /products/:id. The test fails, because the interaction hasn’t been configured in Cypress or Pact
- Add the product/:idinteraction in and voila!
marked this post as
I have a working spike on this, and will publish up an example in the next few days.
we use cypress, but I cannot imagine why and how someone need to integrate end2end testing tool to consumer-driven contracts. Really curious to know what is your idea behind!
Pavel Kruhlei: I want to run (some) Cypress tests against mocked data, and I want to have contracts between the frontend and backend. I think it would be great if those contracts could be used to supply mocks for the aforementioned tests - or equivalently if the test mocks could be used to generate contracts.
Jacob Raihle: Exactly! And apologies Pavel, I must have missed your comment.
One of the biggest challenges with UI tests is that you stub out a backend for performance reasons, or you use a real backend environment (to ensure things actually work). Stubbing is great, but you risk it not being real. Real sucks, because managing e2e test environments is hard.
Being able to reliably produce stubs that match how the real API should behave - and importantly, adapt when your tests adapt, would be a real win.
In fact, I'm catching up with one of the Cypress founders next week to discuss how perhaps we may be able to work together better.