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 want to see you succeed with your contract testing journey. Here’s some ways you can get extra support and have your questions answered:

Pact Slack​

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

Please ask PactFlow specific questions in one of the #pactflow channels below (maintained by SmartBear employees), and direct language specific questions to their respective channel such as #pact-jvm for Java or JVM related questions (maintained by the community).

For PactFlow specific questions, see the following channels:

Getting Started with PactFlow​

Join a contract testing and PactFlow expert for a monthly one hour drop-in session to learn the basics of contract testing with PactFlow and have your questions answered. See the next upcoming session and register to attend.

Stack Overflow​

Stack Overflow is another place you can search for support, the following link will show all questions tagged with pact.

SmartBear customer care and solutions engineers​

If you need PactFlow specific technical support, contact us 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 previously used the open-source Pact Broker for your contract testing needs we migrate the data so that nothing is lost. The process involves:

  1. Moving your existing database to the hosted environment associated with your PactFlow account.
  2. Udating it for full compatibility with PactFlow. This requires 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 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 (for example, a Jenkins build secret or a Travis encrypted environment variable).

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

Consumer​

Although code samples are provided here for some languages to publish Pacts, users are recommended to use the Pact CLI tools, either via Docker, or Standalone.

Pact JS (Node JS)​

const { Publisher } = require("@pact-foundation/pact-cli")
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 the 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​