Implementing the provider changes
The next step is to implement the changes that have been requested in the pact.
Open up the terminal for your provider project.
Run
make testto make sure everything is passing before you start.Get the URL of the new pact:
- Go to your Pactflow account, find the new pact and click "VIEW PACT".
 - Copy the URL from the location bar (discarding any query parameters).
 
Run
PACT_URL=<PACT URL HERE> make testagain. This test should correctly fail with the errorCould not find key "color"in the output.- ๐ This little "verify a custom pact" trick works because of the code in in 
src/product/product.pact.test.jsthat switches between doing a "fetch pacts for these tags" mode and a "verify the pact at the$PACT_URL" mode, based on whether or not the$PACT_URLis set. The$PACT_URLcode path is normally used when the build is triggered by a "contract content changed" webhook, and allows us to verify just the changed pact. 
- ๐ This little "verify a custom pact" trick works because of the code in in 
 Make the test pass by adding a
colorfield toproduct/product.js, and adding the new color argument to the Product initialization lines inproduct/product.repository.jsand the provider states inproduct/product.pact.test.js.class Product {constructor(id, type, name, version, color) {this.id = id;this.type = type;this.name = name;this.version = version;this.color = color;}}class ProductRepository {constructor() {this.products = new Map([["09", new Product("09", "CREDIT_CARD", "Gem Visa", "v1", "green")],["10", new Product("10", "CREDIT_CARD", "28 Degrees", "v1", "blue")],["11", new Product("11", "PERSONAL_LOAN", "MyFlexiPay", "v2", "yellow")],]);}}const opts = {...,stateHandlers: {"product with ID 10 exists": () => {controller.repository.products = new Map([["10", new Product("10", "CREDIT_CARD", "28 Degrees", "v1", "green")]]);},"products exist": () => {controller.repository.products = new Map([["09", new Product("09", "CREDIT_CARD", "Gem Visa", "v1", "blue")],["10", new Product("10", "CREDIT_CARD", "28 Degrees", "v1", "yellow")]]);},Run
PACT_URL=<PACT URL HERE> make testand you should have a passing test suite. โCommit and push your changes.
Expected state by the end of this step
- A provider that implements the features required by the 
feat/new-fieldpact on itsmasterbranch. - The new version of the provider is "deployed" to production.
 - A passing provider build in Travis CI.
 - A 
feat/new-fieldpact in Pactflow that still does not have a verification result. 
Conclusion
The master provider is now compatible with the feat/new-field pact. However, there is no verification result published for the feat/new-field pact, because it was only verified on a development machine, and we don't typically publish verification results from dev machines.
The next step is getting a result back to Pactflow so that the consumer knows they are safe to merge.