Skip to content

Commit fa53d96

Browse files
authored
Merge pull request #86 from pact-foundation/feat/pact-js-v4
Feat/pact js v4
2 parents 69f3c9b + ee011b1 commit fa53d96

File tree

3 files changed

+34
-32
lines changed

3 files changed

+34
-32
lines changed

consumer-js-kafka/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
"dependencies": {
1414
"@faker-js/faker": "^10.0.0",
1515
"cors": "^2.8.5",
16-
"express": "^5.0.1",
16+
"express": "5.1.0",
1717
"kafkajs": "^2.2.4",
18-
"uuid": "^11.0.0"
18+
"uuid": "13.0.0"
1919
},
2020
"devDependencies": {
21-
"@pact-foundation/pact": "^15.0.0",
22-
"dotenv": "^17.0.0",
23-
"eslint": "^9.12.0",
24-
"jest": "^30.0.0"
21+
"@pact-foundation/pact": "16.0.0",
22+
"dotenv": "17.2.2",
23+
"eslint": "9.36.0",
24+
"jest": "30.1.3"
2525
},
2626
"license": "ISC"
2727
}
Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
const {
2-
MatchersV3,
3-
MessageConsumerPact,
4-
asynchronousBodyHandler,
2+
Matchers,
3+
v4AsynchronousBodyHandler,
4+
Pact,
55
} = require("@pact-foundation/pact");
6-
const productEventHandler = require('./product.handler')
7-
const { like, regex } = MatchersV3;
8-
6+
const productEventHandler = require("./product.handler")
7+
const { like, regex } = Matchers;
98
const path = require("path");
109

1110
describe("Kafka handler", () => {
12-
const messagePact = new MessageConsumerPact({
11+
const messagePact = new Pact({
1312
consumer: "pactflow-example-consumer-js-kafka",
1413
dir: path.resolve(process.cwd(), "pacts"),
1514
pactfileWriteMode: "update",
@@ -20,19 +19,22 @@ describe("Kafka handler", () => {
2019
describe("receive a product update", () => {
2120
it("accepts a product event", () => {
2221
return messagePact
23-
.expectsToReceive("a product event update")
24-
.withContent({
25-
id: like("some-uuid-1234-5678"),
26-
type: like("Product Range"),
27-
name: like("Some Product"),
28-
version: like("v1"),
29-
event: regex("^(CREATED|UPDATED|DELETED)$","UPDATED"),
30-
})
31-
.withMetadata({
32-
"contentType": "application/json",
33-
"kafka_topic": "products",
22+
.addAsynchronousInteraction()
23+
.expectsToReceive("a product event update", (builder) => {
24+
builder
25+
.withJSONContent({
26+
id: like("some-uuid-1234-5678"),
27+
type: like("Product Range"),
28+
name: like("Some Product"),
29+
version: like("v1"),
30+
event: regex("^(CREATED|UPDATED|DELETED)$", "UPDATED"),
31+
})
32+
.withMetadata({
33+
"contentType": "application/json",
34+
"kafka_topic": "products",
35+
});
3436
})
35-
.verify(asynchronousBodyHandler(productEventHandler));
37+
.executeTest(v4AsynchronousBodyHandler(productEventHandler));
3638
});
3739
});
3840
});

provider-js-kafka/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@
88
"test": "jest --testTimeout 30000 --testMatch \"**/*.pact.test.js\""
99
},
1010
"dependencies": {
11-
"body-parser": "^2.0.1",
11+
"body-parser": "2.2.0",
1212
"cors": "^2.8.5",
13-
"express": "^5.0.1",
14-
"uuid": "^11.0.0",
13+
"express": "5.1.0",
14+
"uuid": "11.1.0",
1515
"kafkajs": "^2.2.4"
1616
},
1717
"devDependencies": {
18-
"@pact-foundation/pact": "^15.0.0",
19-
"dotenv": "^17.0.0",
20-
"eslint": "^9.12.0",
21-
"jest": "^30.0.0"
18+
"@pact-foundation/pact": "16.0.0",
19+
"dotenv": "17.2.2",
20+
"eslint": "9.36.0",
21+
"jest": "30.1.3"
2222
},
2323
"license": "ISC"
2424
}

0 commit comments

Comments
 (0)