-
Notifications
You must be signed in to change notification settings - Fork 518
/
Copy pathproduct.consumerChange.pact.test.js
41 lines (37 loc) · 1.22 KB
/
product.consumerChange.pact.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require('dotenv').config();
const { Verifier } = require('@pact-foundation/pact');
const {
baseOpts,
setupServer,
stateHandlers,
requestFilter
} = require('./pact.setup');
describe('Pact Verification', () => {
let server;
beforeAll(() => {
server = setupServer();
});
afterAll(() => {
if (server) {
server.close();
}
});
it('validates the expectations of a contract required verification that has been published for this provider', () => {
// For builds triggered by a 'contract_requiring_verification_published' webhook, verify the changed pact against latest of mainBranch and any version currently deployed to an environment
// https://docs.pact.io/pact_broker/webhooks#using-webhooks-with-the-contract_requiring_verification_published-event
// The URL will have been passed in from the webhook to the CI job.
if (!process.env.PACT_URL) {
console.log('no pact url specified');
return;
}
const opts = {
...baseOpts,
pactUrls: [process.env.PACT_URL],
stateHandlers: stateHandlers,
requestFilter: requestFilter
};
return new Verifier(opts).verifyProvider().then(() => {
console.log('Pact Verification Complete!');
});
});
});