-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconsumer.spec.js
47 lines (47 loc) · 2.15 KB
/
consumer.spec.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
42
43
44
45
46
47
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const chai_1 = __importDefault(require("chai"));
const chai_as_promised_1 = __importDefault(require("chai-as-promised"));
const pact_1 = require("@pact-foundation/pact");
const axios_1 = __importDefault(require("axios"));
chai_1.default.use(chai_as_promised_1.default);
const { expect } = chai_1.default;
describe("Pact Consumer Test", () => {
const pact = new pact_1.PactV4({
consumer: "myconsumer",
provider: "myprovider",
spec: pact_1.SpecificationVersion.SPECIFICATION_VERSION_V3,
logLevel: process.env.LOG_LEVEL || "info",
});
it("creates a pact to verify", () => __awaiter(void 0, void 0, void 0, function* () {
yield pact
.addInteraction()
.uponReceiving("a request for dynamic keys")
.withRequest("GET", "/")
.willRespondWith(200, (builder) => {
builder.jsonBody({
foo: pact_1.MatchersV3.like("bar"),
});
})
.executeTest((mockserver) => __awaiter(void 0, void 0, void 0, function* () {
const res = yield axios_1.default.request({
baseURL: mockserver.url,
method: "GET",
url: "/",
});
expect(res.data.foo).to.equal("bar");
}));
}));
});