This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Verifier } from '@pact-foundation/pact'; | |
const providerService = `http://localhost:3378`; | |
describe('Pact Verification', () => { | |
it('should validate the expectations of the consumer service', () => { | |
const brokerOpts = { | |
provider: 'characters-api-application', | |
providerBaseUrl: providerService, | |
pactUrls: [`http://localhost:9292/pacts/provider/characters-api-application/consumer/web-application/latest`], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"scripts": { | |
"test:consumer": "jest --runInBand __tests__/contract/consumer/consumer.spec.js", | |
"publish:broker": "node ./__tests__/contract/broker/publish.js", | |
"publish:pactflow": "pact-broker publish ./pacts --consumer-app-version=1.0.0 --broker-base-url=PACTFLOW_URI --broker-token=PACTFLOW_TOKEN", | |
"up:mock-service": "./node_modules/.bin/json-server ./data/characters.json -p 3378 -w" | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"characters": [ | |
{ | |
"id": 1, | |
"name": "Walter White", | |
"age": 58 | |
}, | |
{ | |
"id": 2, | |
"name": "Michael Scofield", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"scripts": { | |
"test:consumer": "jest --runInBand __tests__/contract/consumer/consumer.spec.js", | |
"publish:broker": "node ./__tests__/contract/broker/publish.js", | |
"publish:pactflow": "pact-broker publish ./pacts --consumer-app-version=1.0.0 --broker-base-url=PACTFLOW_URI --broker-token=PACTFLOW_TOKEN" | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"scripts": { | |
"test:consumer": "jest --runInBand __tests__/contract/consumer/consumer.spec.js", | |
"publish:broker": "node ./__tests__/contract/broker/publish.js" | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('dotenv').config(); | |
const publisher = require('@pact-foundation/pact-node'); | |
const path = require('path'); | |
if (process.env.PACT_LOCAL_BROKER) { | |
const opts = { | |
pactFilesOrDirs: [path.resolve(process.cwd(), 'pacts/')], | |
pactBroker: process.env.PACT_LOCAL_BROKER, | |
tags: ['test'], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"consumer": { | |
"name": "web-application" | |
}, | |
"provider": { | |
"name": "characters-api-application" | |
}, | |
"interactions": [ | |
{ | |
"description": "a request to list all characters", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "testes-de-contrato", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test:consumer": "jest --runInBand __tests__/contract/consumer/consumer.spec.js" | |
}, | |
"keywords": [], | |
"author": "", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MOCK_SERVER_PORT=3377 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dotenv/config'; | |
import axios from 'axios'; | |
const baseUrl = `http://localhost:${process.env.MOCK_SERVER_PORT}`; | |
const fetchCharacters = async () => { | |
return await axios.get(`${baseUrl}/characters`); | |
}; |