Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/caiquecoelho/pact-front-example


https://github.com/caiquecoelho/pact-front-example

Last synced: 19 days ago
JSON representation

Awesome Lists containing this project

README

        

1. Generate Pact Contract in Cypress
Ensure your Cypress test suite is generating a Pact contract. This can be done by making HTTP requests using Pact's pact library in your Cypress tests.

2. Install Pact CLI (if not already installed)
To publish the generated contract, you’ll need the Pact CLI. You can install it globally with npm or yarn:
npm install -g @pact-foundation/pact-cli
3. Publish the Pact Contract
After Cypress generates the contract file, use the Pact CLI to publish it to your Pact Broker. Run this command in your CI/CD pipeline or as a post-test script in your Cypress configuration.

The command structure looks like this:
pact-broker publish --consumer-app-version --broker-base-url --broker-token
Replace the placeholders with:

: Path where the Pact file is saved by Cypress.
: The version of your consumer application (could be a commit hash or version number).
: The URL of your Pact Broker.
: Authentication token if your Pact Broker requires it.
Example:

pact-broker publish ./cypress/pacts --consumer-app-version $(git rev-parse --short HEAD) --broker-base-url https://omega.pactflow.io/ --broker-token

4. Automate in CI/CD Pipeline
Add the publishing command to your CI/CD pipeline (e.g., in a script section of GitHub Actions, CircleCI, or Jenkins) so that the contract is published after every build or test run.

5. Verify the Contract Publishing
Once published, check your Pact Broker dashboard to confirm the contract is available and accessible by your provider services for verification.

This approach integrates Pact contract publishing within Cypress, ensuring every test run can update the contract in the Pact Broker automatically.