Skip to main content

Getting Started with Pactflow

did you know

Pactflow makes testing and deploying microservices at scale, simple and worry free for thousands of developers and testers around the world.

Utilising the Pact framework, create consumer and provider mocks in-platform or use a range of BYO tools to do so through the Bi-Directional Contract Testing feature

Create an account​

If you don’t already have a Pactflow account (have not created one or have not been invited to someone else’s account) get started with our free Starter Plan

Learn about contract testing​

Videos​

New to contract testing? Watch this introductory level video series on contract-testing to understand what it's all about.

Workshops​

Enroll in Pactflow University to dive deeper into the basics of contract testing through to advanced use cases including a CI/CD integration to help you scale

Essential reading​

Here are some key resources to help you on your way:

Getting help​

We also have a Slack workspace where you can chat with other members and get general support with contract or the product. Join us by registering here.

Stack Overflow is another place you can search for support.

And, if you need Pactflow specific technical support, email support@pactflow.io or for help with a PoC or plan options get in touch with sales.

Configuring your API token​

NOTE: You cannot use your username and password to access the Pactflow API.

To publish or verify contracts you need to use one of the bearer tokens from the API Tokens section of your Pactflow settings page.

Open your Pactflow account in a browser and log in with your username and password. Click on the settings icon (the cog wheel icon at the top right of the screen).

You will see the API Tokens page with two tokens listed - a read only token, and a read/write token.

API Token Screen

Contracts and verification results are generally only published from a CI machine, so use the read only token on a local development machine, and keep the read/write token for CI.

While each of the following examples shows the use of a hardcoded token, note that you would normally be accessing the token via an environment variable or build parameter that is stored and provided in a secure manner (eg. a Jenkins build secret or a Travis encrypted environment variable).

To configure the token, click on a tab for your chosen language:

Consumer​

Pact JS (Node JS)​

const { Publisher } = require("@pact-foundation/pact")
const opts = {
pactBroker: 'https://<YOUR_BROKER>.pactflow.io',
pactBrokerToken: '<TOKEN>',
consumerVersion: process.env.GIT_COMMIT
pactFilesOrDirs: ['./pacts'],
};

new Publisher(opts).publishPacts()

Provider​

Pact JS (Node JS)​

const { Verifier } = require("@pact-foundation/pact");

return new Verifier().verifyProvider({
provider: "<Your provider name here>",
providerBaseUrl: "http://localhost:8081",

// Fetch pacts from broker
pactBrokerUrl: "https://<YOUR_BROKER>.pactflow.io/",
pactBrokerToken: "<TOKEN>",

publishVerificationResult: process.env.CI === "true",
providerVersion: process.env.GIT_COMMIT,
});

Supported Tools & Languages​

Pact is available in many different implementations, Click on a language icon to take you to the implementation guide or readme.

The guides cover the consumer-driven contract testing flow.

Consumer-Driven​

Bi-Directional​

Pactflow supports many different testing tools for Bi-Directional Contract Testing.

Click on a testing tool icon to see a demo application you can quickly run to get you started

Consumer Side​

Provider side​