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

See contract testing in action by completing short and easy in-browser tutorials.

And when you’re ready to dive deeper, 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.

Migrating from Pact Broker

When you sign up to the SaaS Pactflow platform we create a new hosted database for you. However if you have previously used the open source Pact Broker for your contract testing needs we can help migrate the data so that nothing is lost. The process involves moving your existing database to the hosted environment associated with your Pactflow account, then updating it for full compatibility with Pactflow. This will require some scheduled down time for the service, including contract publishing and 'can-i-deploy' webhook.

To get started with migrating from Pact Broker contact us at support@pactflow.io with the subject 'migrating from Pact Broker'.

info

Applies to SaaS (Hosted) Pactflow accounts only.

Using On-Premises and want to migrate to the SaaS platform? Check out our on-prem migration guide here.

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