@pact-foundation/pact 11.0.1 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/CONTRIBUTING.md +2 -1
- package/MIGRATION.md +12 -6
- package/README.md +5 -3
- package/package.json +3 -3
- package/scripts/ci/build-and-test.sh +11 -50
- package/scripts/ci/test-examples.sh +64 -0
- package/scripts/install-plugins.sh +4 -0
- package/scripts/trigger-release.sh +1 -1
- package/src/common/net.spec.js +3 -1
- package/src/common/net.spec.js.map +1 -1
- package/src/pact.integration.spec.d.ts +1 -0
- package/src/pact.integration.spec.js +196 -291
- package/src/pact.integration.spec.js.map +1 -1
- package/src/v4/http/index.d.ts +4 -4
- package/src/v4/http/index.js +8 -4
- package/src/v4/http/index.js.map +1 -1
- package/src/v4/http/types.d.ts +4 -5
- package/src/v4/index.js +3 -1
- package/src/v4/index.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [12.0.0](https://github.com/pact-foundation/pact-js/compare/v11.0.2...v12.0.0) (2023-07-10)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### ⚠ BREAKING CHANGES
|
|
9
|
+
|
|
10
|
+
* set node engines min version to 16
|
|
11
|
+
|
|
12
|
+
### Fixes and Improvements
|
|
13
|
+
|
|
14
|
+
* set node engines min version to 16 ([85df5b7](https://github.com/pact-foundation/pact-js/commit/85df5b7c4696a51671d1c8a678ece0fe531c88e2))
|
|
15
|
+
* update to latest pact-core 13.14.0 ([a3085d6](https://github.com/pact-foundation/pact-js/commit/a3085d6901a94ae4a9d9dab5451dab000b9b8456))
|
|
16
|
+
|
|
17
|
+
### [11.0.2](https://github.com/pact-foundation/pact-js/compare/v11.0.1...v11.0.2) (2023-03-09)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Fixes and Improvements
|
|
21
|
+
|
|
22
|
+
* v4 response builder for non-plugin interface ([4da4cb3](https://github.com/pact-foundation/pact-js/commit/4da4cb3e917c541a5633246d6c1f4c4a22d4e5fd)), closes [#1073](https://github.com/pact-foundation/pact-js/issues/1073)
|
|
23
|
+
|
|
5
24
|
### [11.0.1](https://github.com/pact-foundation/pact-js/compare/v11.0.0...v11.0.1) (2023-03-09)
|
|
6
25
|
|
|
7
26
|
|
package/CONTRIBUTING.md
CHANGED
|
@@ -17,8 +17,9 @@ Please provide the following information with your issue to enable us to respond
|
|
|
17
17
|
|
|
18
18
|
## Key Branches
|
|
19
19
|
|
|
20
|
-
* `master` - this is the current main version supporting the
|
|
20
|
+
* `master` - this is the current main version supporting the 11.x.x release line. Most investment will be here, including major new features, enhancements, bug fixes, security patches etc.
|
|
21
21
|
* `9.x.x` - this is the previous major version supporting the 9.x.x release line. Critical security patches and bug fixes will be provided as a priority.
|
|
22
|
+
* There is no tracking or release branch for 10.x.x at this stage. Most users can be encouraged to jump straight to 11.x.x noting the single breaking change (see the migration guide)
|
|
22
23
|
|
|
23
24
|
## I want to contribute code but don't know where to start
|
|
24
25
|
|
package/MIGRATION.md
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
# Pact-js migration guide
|
|
2
2
|
|
|
3
|
+
# 10.x.x -> 11.x.x
|
|
4
|
+
|
|
5
|
+
There is just one single [breaking change](https://github.com/pact-foundation/pact-js/blob/master/CHANGELOG.md#-breaking-changes) in this release. A conflicting type `StateHandlers` has been renamed to `MessageStateHandlers` for use in message pact tests.
|
|
6
|
+
|
|
3
7
|
# 9.x.x -> 10.x.x
|
|
4
8
|
|
|
5
9
|
See the [9.x.x -> 10.x.x](/docs/migrations/9-10.md) migration guide.
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
For changes on the intermediate beta versions, see below:
|
|
12
|
+
|
|
13
|
+
## 10.0.0-beta.62
|
|
8
14
|
|
|
9
15
|
Removed the default export for v3 in the root package in preparation for a release.
|
|
10
16
|
|
|
11
|
-
|
|
17
|
+
## 10.0.0-beta.61
|
|
12
18
|
|
|
13
19
|
* new `addInteraction` method on PactV3 to support previous JSON-style interactions
|
|
14
20
|
* remove `VerifierV3` as many beta versions have passed with this deprecation notice and won't be in final release
|
|
@@ -23,7 +29,7 @@ Removed the default export for v3 in the root package in preparation for a relea
|
|
|
23
29
|
* the `mockService` property on the `Pact` class is no longer an actual `MockService`, but supports the `baseUrl` property.
|
|
24
30
|
* Manually controlling the state of the mock server - such as removing interactions - has been removed.
|
|
25
31
|
|
|
26
|
-
|
|
32
|
+
## 10.0.0-beta.56
|
|
27
33
|
|
|
28
34
|
Migrates to a new handle based verifier. This adds several layers of improvement, including better error handling/response output (which will be added in later versions).
|
|
29
35
|
|
|
@@ -31,7 +37,7 @@ Migrates to a new handle based verifier. This adds several layers of improvement
|
|
|
31
37
|
* Handle based verifier doesn't support environment variables (i.e. `PACT_BROKER_*`)
|
|
32
38
|
|
|
33
39
|
This guide is for migrating to a new version of pact-js.
|
|
34
|
-
|
|
40
|
+
## 10.0.0-beta.52
|
|
35
41
|
|
|
36
42
|
The following matchers now must have an explicit example provided:
|
|
37
43
|
|
|
@@ -39,13 +45,13 @@ The following matchers now must have an explicit example provided:
|
|
|
39
45
|
* `timestamp`
|
|
40
46
|
* `time`
|
|
41
47
|
|
|
42
|
-
|
|
48
|
+
## 10.0.0-beta.47
|
|
43
49
|
|
|
44
50
|
Change uses of `RFC3339_TIMESTAMP_FORMAT` or `Matchers.rfc1123Timestamp()` to
|
|
45
51
|
`RFC1123_TIMESTAMP_FORMAT` and `rfc1123Timestamp` respectively (this matcher
|
|
46
52
|
has always been RFC1123, not RFC3339).
|
|
47
53
|
|
|
48
|
-
|
|
54
|
+
## 10.0.0-beta.44 to beta.45
|
|
49
55
|
|
|
50
56
|
You no longer need to use `VerifierV3`. You may now do:
|
|
51
57
|
|
package/README.md
CHANGED
|
@@ -248,8 +248,9 @@ It's best to run Pact verification tests as part of your unit testing suite, so
|
|
|
248
248
|
|
|
249
249
|
| Version | Stable | [Spec] Compatibility | Install |
|
|
250
250
|
| ------- | ------ | -------------------- | ------------------ |
|
|
251
|
-
|
|
|
252
|
-
|
|
|
251
|
+
| 11.x.x | Yes | 2, 3, 4 | See [installation] |
|
|
252
|
+
| 10.x.x | Yes | 2, 3, 4 | See [installation] |
|
|
253
|
+
| 9.x.x | Yes | 2, 3\* | [9xx] |
|
|
253
254
|
|
|
254
255
|
_\*_ v3 support is limited to the subset of functionality required to enable language inter-operable [Message support].
|
|
255
256
|
|
|
@@ -268,7 +269,8 @@ See [CONTRIBUTING](CONTRIBUTING.md).
|
|
|
268
269
|
<br />
|
|
269
270
|
|
|
270
271
|
[spec]: https://github.com/pact-foundation/pact-specification
|
|
271
|
-
[
|
|
272
|
+
[10xx]: https://github.com/pact-foundation/pact-js/tree/10.x.x
|
|
273
|
+
[9xx]: https://github.com/pact-foundation/pact-js/tree/9.x.x
|
|
272
274
|
[pact website]: http://docs.pact.io/
|
|
273
275
|
[@pact_up]: https://twitter.com/pact_up
|
|
274
276
|
[pact specification v2]: https://github.com/pact-foundation/pact-specification/tree/version-2
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pact-foundation/pact",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.0",
|
|
4
4
|
"description": "Pact for all things Javascript",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"url": "git+https://github.com/pact-foundation/pact-js.git"
|
|
26
26
|
},
|
|
27
27
|
"engines": {
|
|
28
|
-
"node": ">=
|
|
28
|
+
"node": ">=16"
|
|
29
29
|
},
|
|
30
30
|
"keywords": [
|
|
31
31
|
"pact",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
]
|
|
96
96
|
},
|
|
97
97
|
"dependencies": {
|
|
98
|
-
"@pact-foundation/pact-core": "^
|
|
98
|
+
"@pact-foundation/pact-core": "^14.0.1",
|
|
99
99
|
"@types/express": "^4.17.11",
|
|
100
100
|
"axios": "^0.27.2",
|
|
101
101
|
"body-parser": "^1.20.0",
|
|
@@ -6,8 +6,7 @@ set -x
|
|
|
6
6
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd)" # Figure out where the script is running
|
|
7
7
|
. "$SCRIPT_DIR"/lib/robust-bash.sh
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
npm ci
|
|
9
|
+
npm ci --ignore-scripts
|
|
11
10
|
|
|
12
11
|
npm run dist
|
|
13
12
|
cp package.json ./dist
|
|
@@ -19,54 +18,16 @@ export PACT_BROKER_PASSWORD="O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1"
|
|
|
19
18
|
|
|
20
19
|
"${SCRIPT_DIR}"/lib/prepare-release.sh
|
|
21
20
|
|
|
22
|
-
cp package-lock.json dist
|
|
23
|
-
cp -r scripts dist
|
|
24
|
-
echo "This will be version '$(npx absolute-version)'"
|
|
25
|
-
|
|
26
|
-
# Link the build so that the examples are always testing the
|
|
27
|
-
# current build, in it's properly exported format
|
|
28
|
-
(cd dist && npm ci)
|
|
29
|
-
|
|
30
|
-
echo "Running e2e examples build for node version $(node --version)"
|
|
31
|
-
for i in examples/*; do
|
|
32
|
-
[ -d "$i" ] || continue # prevent failure if not a directory
|
|
33
|
-
[ -e "$i" ] || continue # prevent failure if there are no examples
|
|
34
|
-
echo "--> running tests for: $i"
|
|
35
|
-
pushd "$i"
|
|
36
|
-
# replace pact dependency with locally build version
|
|
37
|
-
contents="$(jq '.devDependencies."@pact-foundation/pact" = "file:../../dist"' package.json)" && \
|
|
38
|
-
echo "${contents}" > package.json
|
|
39
|
-
# npm ci does not work because we have just changed the package.json file
|
|
40
|
-
npm install
|
|
41
|
-
npm test
|
|
42
|
-
popd
|
|
43
|
-
done
|
|
44
|
-
|
|
45
21
|
echo "--> Running coverage checks"
|
|
46
22
|
npm run coverage
|
|
47
23
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
for i in examples/v*/*; do
|
|
59
|
-
[ -d "$i" ] || continue # prevent failure if not a directory
|
|
60
|
-
[ -e "$i" ] || continue # prevent failure if there are no examples
|
|
61
|
-
echo "------------------------------------------------"
|
|
62
|
-
echo "------------> continuing to test V3/v$ example project: $i"
|
|
63
|
-
node --version
|
|
64
|
-
pushd "$i"
|
|
65
|
-
# replace pact dependency with locally build version
|
|
66
|
-
contents="$(jq '.devDependencies."@pact-foundation/pact" = "file:../../../dist"' package.json)" && \
|
|
67
|
-
echo "${contents}" > package.json
|
|
68
|
-
# npm ci does not work because we have just changed the package.json file
|
|
69
|
-
npm install
|
|
70
|
-
npm test
|
|
71
|
-
popd
|
|
72
|
-
done
|
|
24
|
+
cp package-lock.json dist
|
|
25
|
+
cp -r scripts dist
|
|
26
|
+
echo "This will be version '$(npx --yes absolute-version)'"
|
|
27
|
+
|
|
28
|
+
if [ x"${SKIP_EXAMPLES:-}" == "x" ]; then
|
|
29
|
+
echo "running all examples as SKIP_EXAMPLES not set"
|
|
30
|
+
"${SCRIPT_DIR}"/test-examples.sh
|
|
31
|
+
else
|
|
32
|
+
echo "skipping examples as SKIP_EXAMPLES set"
|
|
33
|
+
fi
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/bin/bash -eu
|
|
2
|
+
set -e
|
|
3
|
+
set -u
|
|
4
|
+
set -x
|
|
5
|
+
|
|
6
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd)" # Figure out where the script is running
|
|
7
|
+
. "$SCRIPT_DIR"/lib/robust-bash.sh
|
|
8
|
+
|
|
9
|
+
# Link the build so that the examples are always testing the
|
|
10
|
+
# current build, in it's properly exported format
|
|
11
|
+
(cd dist && npm ci --ignore-scripts)
|
|
12
|
+
|
|
13
|
+
echo "Running e2e examples build for node version $(node --version)"
|
|
14
|
+
for i in examples/*; do
|
|
15
|
+
[ -d "$i" ] || continue # prevent failure if not a directory
|
|
16
|
+
[ -e "$i" ] || continue # prevent failure if there are no examples
|
|
17
|
+
echo "--> running tests for: $i"
|
|
18
|
+
pushd "$i"
|
|
19
|
+
# replace pact dependency with locally build version
|
|
20
|
+
contents="$(jq '.devDependencies."@pact-foundation/pact" = "file:../../dist"' package.json)" && \
|
|
21
|
+
echo "${contents}" > package.json
|
|
22
|
+
|
|
23
|
+
if [ x"${SETUP_DIST_ONLY:-}" == "x" ]; then
|
|
24
|
+
echo "running all examples as SETUP_DIST_ONLY not set"
|
|
25
|
+
# npm ci does not work because we have just changed the package.json file
|
|
26
|
+
npm install --ignore-scripts
|
|
27
|
+
npm test
|
|
28
|
+
else
|
|
29
|
+
echo "skipping testing of examples as SETUP_DIST_ONLY set"
|
|
30
|
+
fi
|
|
31
|
+
popd
|
|
32
|
+
done
|
|
33
|
+
|
|
34
|
+
echo "Running Vx examples build"
|
|
35
|
+
|
|
36
|
+
# Commented because:
|
|
37
|
+
# 1. We can't run the broker on windows CI
|
|
38
|
+
# 2. We use the live broker in the v3 examples now anyway
|
|
39
|
+
# docker pull pactfoundation/pact-broker
|
|
40
|
+
# BROKER_ID=$(docker run -e PACT_BROKER_DATABASE_ADAPTER=sqlite -d -p 9292:9292 pactfoundation/pact-broker)
|
|
41
|
+
|
|
42
|
+
# trap "docker kill $BROKER_ID" EXIT
|
|
43
|
+
|
|
44
|
+
for i in examples/v*/*; do
|
|
45
|
+
[ -d "$i" ] || continue # prevent failure if not a directory
|
|
46
|
+
[ -e "$i" ] || continue # prevent failure if there are no examples
|
|
47
|
+
echo "------------------------------------------------"
|
|
48
|
+
echo "------------> continuing to test V3/v$ example project: $i"
|
|
49
|
+
node --version
|
|
50
|
+
pushd "$i"
|
|
51
|
+
# replace pact dependency with locally build version
|
|
52
|
+
contents="$(jq '.devDependencies."@pact-foundation/pact" = "file:../../../dist"' package.json)" && \
|
|
53
|
+
echo "${contents}" > package.json
|
|
54
|
+
# npm ci does not work because we have just changed the package.json file
|
|
55
|
+
if [ x"${SETUP_DIST_ONLY:-}" == "x" ]; then
|
|
56
|
+
echo "running all examples as SETUP_DIST_ONLY not set"
|
|
57
|
+
# npm ci does not work because we have just changed the package.json file
|
|
58
|
+
npm install --ignore-scripts
|
|
59
|
+
npm test
|
|
60
|
+
else
|
|
61
|
+
echo "skipping testing of examples as SETUP_DIST_ONLY set"
|
|
62
|
+
fi
|
|
63
|
+
popd
|
|
64
|
+
done
|
package/src/common/net.spec.js
CHANGED
|
@@ -26,7 +26,9 @@ describe('Net', function () {
|
|
|
26
26
|
});
|
|
27
27
|
});
|
|
28
28
|
};
|
|
29
|
-
|
|
29
|
+
(process.platform === 'linux' && process.arch === 'arm64'
|
|
30
|
+
? describe.skip
|
|
31
|
+
: describe)('#isPortAvailable', function () {
|
|
30
32
|
context('when the port is not allowed to be bound', function () {
|
|
31
33
|
it('returns a rejected promise', function () {
|
|
32
34
|
return expect((0, net_2.isPortAvailable)(specialPort, defaultHost)).to.eventually.be
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"net.spec.js","sourceRoot":"","sources":["../../../src/common/net.spec.ts"],"names":[],"mappings":";;;;;AAAA,8CAAwB;AACxB,sEAA8C;AAC9C,4CAA0B;AAC1B,6BAAwC;AACxC,oDAA8B;AAEtB,IAAA,MAAM,GAAK,cAAI,OAAT,CAAU;AAExB,cAAI,CAAC,GAAG,CAAC,0BAAc,CAAC,CAAC;AAEzB,QAAQ,CAAC,KAAK,EAAE;IACd,IAAM,IAAI,GAAG,IAAI,CAAC;IAClB,IAAM,WAAW,GAAG,SAAS,CAAC;IAC9B,IAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CA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86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
// Accept: "application/json",
|
|
198
|
-
// },
|
|
199
|
-
// },
|
|
200
|
-
// willRespondWith: {
|
|
201
|
-
// status: 200,
|
|
202
|
-
// headers: {
|
|
203
|
-
// "Content-Type": "application/json",
|
|
204
|
-
// },
|
|
205
|
-
// body: EXPECTED_BODY,
|
|
206
|
-
// },
|
|
207
|
-
// })
|
|
208
|
-
// const interaction2 = provider.addInteraction({
|
|
209
|
-
// state: "i have a list of projects",
|
|
210
|
-
// uponReceiving: "a request for a project that does not exist",
|
|
211
|
-
// withRequest: {
|
|
212
|
-
// method: HTTPMethod.GET,
|
|
213
|
-
// path: "/projects/2",
|
|
214
|
-
// headers: {
|
|
215
|
-
// Accept: "application/json",
|
|
216
|
-
// },
|
|
217
|
-
// },
|
|
218
|
-
// willRespondWith: {
|
|
219
|
-
// status: 404,
|
|
220
|
-
// headers: {
|
|
221
|
-
// "Content-Type": "application/json",
|
|
222
|
-
// },
|
|
223
|
-
// },
|
|
224
|
-
// })
|
|
225
|
-
// return Promise.all([interaction1, interaction2])
|
|
226
|
-
// })
|
|
227
|
-
// it("allows two requests", () => {
|
|
228
|
-
// const verificationPromise = superagent
|
|
229
|
-
// .get(`${PROVIDER_URL}/projects`)
|
|
230
|
-
// .set({
|
|
231
|
-
// Accept: "application/json",
|
|
232
|
-
// })
|
|
233
|
-
// .then((res: any) => res.text)
|
|
234
|
-
// const verificationPromise404 = superagent
|
|
235
|
-
// .get(`${PROVIDER_URL}/projects/2`)
|
|
236
|
-
// .set({
|
|
237
|
-
// Accept: "application/json",
|
|
238
|
-
// })
|
|
239
|
-
// return Promise.all([
|
|
240
|
-
// expect(verificationPromise).to.eventually.equal(
|
|
241
|
-
// JSON.stringify(EXPECTED_BODY)
|
|
242
|
-
// ),
|
|
243
|
-
// expect(verificationPromise404).to.eventually.be.rejected,
|
|
244
|
-
// ])
|
|
245
|
-
// })
|
|
246
|
-
// // verify with Pact, and reset expectations
|
|
247
|
-
// it("successfully verifies", () => provider.verify())
|
|
248
|
-
// })
|
|
249
|
-
// context("with an unexpected interaction", () => {
|
|
250
|
-
// // add interactions, as many as needed
|
|
251
|
-
// before(() =>
|
|
252
|
-
// provider
|
|
253
|
-
// .addInteraction({
|
|
254
|
-
// state: "i have a list of projects",
|
|
255
|
-
// uponReceiving: "a request for projects",
|
|
256
|
-
// withRequest: {
|
|
257
|
-
// method: HTTPMethod.GET,
|
|
258
|
-
// path: "/projects",
|
|
259
|
-
// headers: {
|
|
260
|
-
// Accept: "application/json",
|
|
261
|
-
// },
|
|
262
|
-
// },
|
|
263
|
-
// willRespondWith: {
|
|
264
|
-
// status: 200,
|
|
265
|
-
// headers: {
|
|
266
|
-
// "Content-Type": "application/json",
|
|
267
|
-
// },
|
|
268
|
-
// body: EXPECTED_BODY,
|
|
269
|
-
// },
|
|
270
|
-
// })
|
|
271
|
-
// .then(
|
|
272
|
-
// () => console.log("Adding interaction worked"),
|
|
273
|
-
// () => console.warn("Adding interaction failed.")
|
|
274
|
-
// )
|
|
275
|
-
// )
|
|
276
|
-
// it("fails verification", () => {
|
|
277
|
-
// const verificationPromise = superagent
|
|
278
|
-
// .get(`${PROVIDER_URL}/projects`)
|
|
279
|
-
// .set({ Accept: "application/json" })
|
|
280
|
-
// .then(() =>
|
|
281
|
-
// superagent.delete(`${PROVIDER_URL}/projects/2`).catch(() => {})
|
|
282
|
-
// )
|
|
283
|
-
// .then(() => provider.verify())
|
|
284
|
-
// return expect(verificationPromise).to.be.rejectedWith(
|
|
285
|
-
// "Pact verification failed - expected interactions did not match actual."
|
|
286
|
-
// )
|
|
287
|
-
// })
|
|
288
|
-
// })
|
|
289
|
-
// })
|
|
290
|
-
// })
|
|
291
|
-
// })
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
/* tslint:disable:no-unused-expression no-empty */
|
|
43
|
+
var chai_1 = __importDefault(require("chai"));
|
|
44
|
+
var chai_as_promised_1 = __importDefault(require("chai-as-promised"));
|
|
45
|
+
var sinon_chai_1 = __importDefault(require("sinon-chai"));
|
|
46
|
+
var axios_1 = __importDefault(require("axios"));
|
|
47
|
+
var net = require("net");
|
|
48
|
+
process.env.ENABLE_FEATURE_V4 = 'true';
|
|
49
|
+
// eslint-disable-next-line import/first
|
|
50
|
+
var v4_1 = require("./v4");
|
|
51
|
+
var expect = chai_1.default.expect;
|
|
52
|
+
chai_1.default.use(sinon_chai_1.default);
|
|
53
|
+
chai_1.default.use(chai_as_promised_1.default);
|
|
54
|
+
describe('V4 Pact', function () {
|
|
55
|
+
var pact;
|
|
56
|
+
beforeEach(function () {
|
|
57
|
+
pact = new v4_1.PactV4({
|
|
58
|
+
consumer: 'v4consumer',
|
|
59
|
+
provider: 'v4provider',
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
describe('HTTP req/res contract', function () {
|
|
63
|
+
it('generates a pact', function () {
|
|
64
|
+
return pact
|
|
65
|
+
.addInteraction()
|
|
66
|
+
.given('some state')
|
|
67
|
+
.given('a second state')
|
|
68
|
+
.uponReceiving('a standard HTTP req/res')
|
|
69
|
+
.withRequest('POST', '/', function (builder) {
|
|
70
|
+
builder
|
|
71
|
+
.jsonBody({
|
|
72
|
+
foo: 'bar',
|
|
73
|
+
})
|
|
74
|
+
.headers({
|
|
75
|
+
'x-foo': 'x-bar',
|
|
76
|
+
});
|
|
77
|
+
})
|
|
78
|
+
.willRespondWith(200, function (builder) {
|
|
79
|
+
builder
|
|
80
|
+
.jsonBody({
|
|
81
|
+
foo: 'bar',
|
|
82
|
+
})
|
|
83
|
+
.headers({
|
|
84
|
+
'x-foo': 'x-bar',
|
|
85
|
+
});
|
|
86
|
+
})
|
|
87
|
+
.executeTest(function (server) { return __awaiter(void 0, void 0, void 0, function () {
|
|
88
|
+
return __generator(this, function (_a) {
|
|
89
|
+
return [2 /*return*/, axios_1.default.post(server.url, {
|
|
90
|
+
foo: 'bar',
|
|
91
|
+
}, {
|
|
92
|
+
headers: {
|
|
93
|
+
'x-foo': 'x-bar',
|
|
94
|
+
},
|
|
95
|
+
})];
|
|
96
|
+
});
|
|
97
|
+
}); });
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
describe('Plugin test', function () {
|
|
101
|
+
describe('Using the MATT plugin', function () {
|
|
102
|
+
var parseMattMessage = function (raw) {
|
|
103
|
+
return raw.replace(/(MATT)+/g, '').trim();
|
|
104
|
+
};
|
|
105
|
+
var generateMattMessage = function (raw) { return "MATT".concat(raw, "MATT"); };
|
|
106
|
+
describe('HTTP interface', function () {
|
|
107
|
+
it('generates a pact', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
108
|
+
var mattRequest, mattResponse;
|
|
109
|
+
return __generator(this, function (_a) {
|
|
110
|
+
switch (_a.label) {
|
|
111
|
+
case 0:
|
|
112
|
+
mattRequest = "{\"request\": {\"body\": \"hello\"}}";
|
|
113
|
+
mattResponse = "{\"response\":{\"body\":\"world\"}}";
|
|
114
|
+
return [4 /*yield*/, pact
|
|
115
|
+
.addInteraction()
|
|
116
|
+
.given('the Matt protocol exists')
|
|
117
|
+
.uponReceiving('an HTTP request to /matt')
|
|
118
|
+
.usingPlugin({
|
|
119
|
+
plugin: 'matt',
|
|
120
|
+
version: '0.0.7',
|
|
121
|
+
})
|
|
122
|
+
.withRequest('POST', '/matt', function (builder) {
|
|
123
|
+
builder.pluginContents('application/matt', mattRequest);
|
|
124
|
+
})
|
|
125
|
+
.willRespondWith(200, function (builder) {
|
|
126
|
+
builder.pluginContents('application/matt', mattResponse);
|
|
127
|
+
})
|
|
128
|
+
.executeTest(function (mockserver) {
|
|
129
|
+
return axios_1.default
|
|
130
|
+
.request({
|
|
131
|
+
baseURL: mockserver.url,
|
|
132
|
+
headers: {
|
|
133
|
+
'content-type': 'application/matt',
|
|
134
|
+
Accept: 'application/matt',
|
|
135
|
+
},
|
|
136
|
+
data: generateMattMessage('hello'),
|
|
137
|
+
method: 'POST',
|
|
138
|
+
url: '/matt',
|
|
139
|
+
})
|
|
140
|
+
.then(function (res) {
|
|
141
|
+
expect(parseMattMessage(res.data)).to.eq('world');
|
|
142
|
+
});
|
|
143
|
+
})];
|
|
144
|
+
case 1:
|
|
145
|
+
_a.sent();
|
|
146
|
+
return [2 /*return*/];
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}); });
|
|
150
|
+
});
|
|
151
|
+
describe('Synchronous Message (TCP) ', function () {
|
|
152
|
+
describe('with MATT protocol', function () {
|
|
153
|
+
var HOST = '127.0.0.1';
|
|
154
|
+
var sendMattMessageTCP = function (message, host, port) {
|
|
155
|
+
var socket = net.connect({
|
|
156
|
+
port: port,
|
|
157
|
+
host: host,
|
|
158
|
+
});
|
|
159
|
+
var res = socket.write("".concat(generateMattMessage(message), "\n"));
|
|
160
|
+
if (!res) {
|
|
161
|
+
throw Error('unable to connect to host');
|
|
162
|
+
}
|
|
163
|
+
return new Promise(function (resolve) {
|
|
164
|
+
socket.on('data', function (data) {
|
|
165
|
+
resolve(parseMattMessage(data.toString()));
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
};
|
|
169
|
+
it('generates a pact', function () {
|
|
170
|
+
var mattMessage = "{\"request\": {\"body\": \"hellotcp\"}, \"response\":{\"body\":\"tcpworld\"}}";
|
|
171
|
+
return pact
|
|
172
|
+
.addSynchronousInteraction('a MATT message')
|
|
173
|
+
.usingPlugin({
|
|
174
|
+
plugin: 'matt',
|
|
175
|
+
version: '0.0.7',
|
|
176
|
+
})
|
|
177
|
+
.withPluginContents(mattMessage, 'application/matt')
|
|
178
|
+
.startTransport('matt', HOST)
|
|
179
|
+
.executeTest(function (tc) { return __awaiter(void 0, void 0, void 0, function () {
|
|
180
|
+
var message;
|
|
181
|
+
return __generator(this, function (_a) {
|
|
182
|
+
switch (_a.label) {
|
|
183
|
+
case 0: return [4 /*yield*/, sendMattMessageTCP('hellotcp', HOST, tc.port)];
|
|
184
|
+
case 1:
|
|
185
|
+
message = _a.sent();
|
|
186
|
+
expect(message).to.eq('tcpworld');
|
|
187
|
+
return [2 /*return*/];
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
}); });
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
});
|
|
292
197
|
//# sourceMappingURL=pact.integration.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pact.integration.spec.js","sourceRoot":"","sources":["../../src/pact.integration.spec.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"pact.integration.spec.js","sourceRoot":"","sources":["../../src/pact.integration.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAkD;AAClD,8CAAwB;AACxB,sEAA8C;AAC9C,0DAAmC;AACnC,gDAA0B;AAC1B,yBAA4B;AAE5B,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,MAAM,CAAC;AAEvC,wCAA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M,kBAAkB,CACtC,UAAU,EACV,IAAI,EACJ,EAAE,CAAC,IAAI,CACR,EAAA;;wCAJK,OAAO,GAAG,SAIf;wCACD,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC;;;;6BACnC,CAAC,CAAC;oBACP,CAAC,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/src/v4/http/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { ConsumerInteraction, ConsumerPact } from '@pact-foundation/pact-core';
|
|
3
3
|
import { JsonMap } from '../../common/jsonTypes';
|
|
4
4
|
import { Path, TemplateHeaders, TemplateQuery } from '../../v3';
|
|
5
|
-
import { AnyTemplate } from '../../v3/matchers';
|
|
6
5
|
import { PactV4Options, PluginConfig, V4InteractionWithCompleteRequest, V4InteractionWithPlugin, V4InteractionwithRequest, V4InteractionWithResponse, V4MockServer, V4Request, V4RequestBuilder, V4RequestBuilderFunc, V4ResponseBuilder, V4ResponseBuilderFunc, V4UnconfiguredInteraction, V4Response, V4InteractionWithPluginRequest, V4PluginResponseBuilderFunc, V4InteractionWithPluginResponse, V4RequestWithPluginBuilder, V4ResponseWithPluginBuilder, V4PluginRequestBuilderFunc, TestFunction } from './types';
|
|
7
6
|
export declare class UnconfiguredInteraction implements V4UnconfiguredInteraction {
|
|
8
7
|
protected pact: ConsumerPact;
|
|
@@ -19,7 +18,8 @@ export declare class InteractionWithCompleteRequest implements V4InteractionWith
|
|
|
19
18
|
private pact;
|
|
20
19
|
private interaction;
|
|
21
20
|
private opts;
|
|
22
|
-
|
|
21
|
+
private request;
|
|
22
|
+
constructor(pact: ConsumerPact, interaction: ConsumerInteraction, opts: PactV4Options, request: V4Request);
|
|
23
23
|
withCompleteResponse(response: V4Response): V4InteractionWithResponse;
|
|
24
24
|
}
|
|
25
25
|
export declare class InteractionwithRequest implements V4InteractionwithRequest {
|
|
@@ -34,7 +34,7 @@ export declare class RequestBuilder implements V4RequestBuilder {
|
|
|
34
34
|
constructor(interaction: ConsumerInteraction);
|
|
35
35
|
query(query: TemplateQuery): this;
|
|
36
36
|
headers(headers: TemplateHeaders): this;
|
|
37
|
-
jsonBody(body:
|
|
37
|
+
jsonBody(body: unknown): this;
|
|
38
38
|
binaryFile(contentType: string, file: string): this;
|
|
39
39
|
multipartBody(contentType: string, file: string, mimePartName: string): this;
|
|
40
40
|
body(contentType: string, body: Buffer): this;
|
|
@@ -43,7 +43,7 @@ export declare class ResponseBuilder implements V4ResponseBuilder {
|
|
|
43
43
|
protected interaction: ConsumerInteraction;
|
|
44
44
|
constructor(interaction: ConsumerInteraction);
|
|
45
45
|
headers(headers: TemplateHeaders): this;
|
|
46
|
-
jsonBody(body:
|
|
46
|
+
jsonBody(body: unknown): this;
|
|
47
47
|
binaryFile(contentType: string, file: string): this;
|
|
48
48
|
multipartBody(contentType: string, file: string, mimePartName: string): this;
|
|
49
49
|
body(contentType: string, body: Buffer): this;
|
package/src/v4/http/index.js
CHANGED
|
@@ -84,7 +84,7 @@ var UnconfiguredInteraction = /** @class */ (function () {
|
|
|
84
84
|
return this;
|
|
85
85
|
};
|
|
86
86
|
UnconfiguredInteraction.prototype.withCompleteRequest = function (request) {
|
|
87
|
-
return new InteractionWithCompleteRequest(this.pact, this.interaction, this.opts);
|
|
87
|
+
return new InteractionWithCompleteRequest(this.pact, this.interaction, this.opts, request);
|
|
88
88
|
};
|
|
89
89
|
UnconfiguredInteraction.prototype.withRequest = function (method, path, builder) {
|
|
90
90
|
this.interaction.withRequest(method, (0, matchers_1.matcherValueOrString)(path));
|
|
@@ -101,11 +101,11 @@ var UnconfiguredInteraction = /** @class */ (function () {
|
|
|
101
101
|
}());
|
|
102
102
|
exports.UnconfiguredInteraction = UnconfiguredInteraction;
|
|
103
103
|
var InteractionWithCompleteRequest = /** @class */ (function () {
|
|
104
|
-
|
|
105
|
-
function InteractionWithCompleteRequest(pact, interaction, opts) {
|
|
104
|
+
function InteractionWithCompleteRequest(pact, interaction, opts, request) {
|
|
106
105
|
this.pact = pact;
|
|
107
106
|
this.interaction = interaction;
|
|
108
107
|
this.opts = opts;
|
|
108
|
+
this.request = request;
|
|
109
109
|
throw Error('V4InteractionWithCompleteRequest is unimplemented');
|
|
110
110
|
}
|
|
111
111
|
InteractionWithCompleteRequest.prototype.withCompleteResponse = function (response) {
|
|
@@ -122,6 +122,10 @@ var InteractionwithRequest = /** @class */ (function () {
|
|
|
122
122
|
this.opts = opts;
|
|
123
123
|
}
|
|
124
124
|
InteractionwithRequest.prototype.willRespondWith = function (status, builder) {
|
|
125
|
+
this.interaction.withStatus(status);
|
|
126
|
+
if (typeof builder === 'function') {
|
|
127
|
+
builder(new ResponseBuilder(this.interaction));
|
|
128
|
+
}
|
|
125
129
|
return new InteractionWithResponse(this.pact, this.interaction, this.opts);
|
|
126
130
|
};
|
|
127
131
|
return InteractionwithRequest;
|
|
@@ -181,7 +185,6 @@ var RequestBuilder = /** @class */ (function () {
|
|
|
181
185
|
}());
|
|
182
186
|
exports.RequestBuilder = RequestBuilder;
|
|
183
187
|
var ResponseBuilder = /** @class */ (function () {
|
|
184
|
-
// tslint:disable:no-empty-function
|
|
185
188
|
function ResponseBuilder(interaction) {
|
|
186
189
|
this.interaction = interaction;
|
|
187
190
|
}
|
|
@@ -259,6 +262,7 @@ var InteractionWithPluginRequest = /** @class */ (function () {
|
|
|
259
262
|
this.opts = opts;
|
|
260
263
|
}
|
|
261
264
|
InteractionWithPluginRequest.prototype.willRespondWith = function (status, builder) {
|
|
265
|
+
this.interaction.withStatus(status);
|
|
262
266
|
if (typeof builder === 'function') {
|
|
263
267
|
builder(new ResponseWithPluginBuilder(this.interaction));
|
|
264
268
|
}
|
package/src/v4/http/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/v4/http/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,+BAA0C;AAE1C,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/v4/http/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,+BAA0C;AAE1C,8CAAkE;AAwBlE,uBAA0B;AAC1B,4CAG0B;AAC1B,+DAAyC;AAIzC;IACE,mCAAmC;IACnC,iCACY,IAAkB,EAClB,WAAgC,EAChC,IAAmB;QAFnB,SAAI,GAAJ,IAAI,CAAc;QAClB,gBAAW,GAAX,WAAW,CAAqB;QAChC,SAAI,GAAJ,IAAI,CAAe;IAC5B,CAAC;IAEJ,+CAAa,GAAb,UAAc,WAAmB;QAC/B,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;QAE5C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,uCAAK,GAAL,UAAM,KAAa,EAAE,UAAoB;QAAzC,iBAUC;QATC,IAAI,UAAU,EAAE;YACd,IAAA,yBAAiB,EAAC,UAAC,CAAC,EAAE,CAAC;gBACrB,KAAI,CAAC,WAAW,CAAC,cAAc,CAAC,KAAK,EAAE,UAAG,CAAC,CAAE,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;YACpE,CAAC,EAAE,UAAU,CAAC,CAAC;SAChB;aAAM;YACL,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SAC/B;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,qDAAmB,GAAnB,UAAoB,OAAkB;QACpC,OAAO,IAAI,8BAA8B,CACvC,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,IAAI,EACT,OAAO,CACR,CAAC;IACJ,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CAAC;;;gBAGN,eAAe,GAAG,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;gBAClD,MAAM,GAAG,IAAA,kCAAwB,EAAC,eAAe,CAAC,CAAC;gBACnD,OAAO,GAAG,IAAI,CAAC,6BAA6B,CAAC,IAAI,CAAC,CAAC;gBAEzD,mCAAmC;gBACnC,IAAI,CAAC,OAAO,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;oBAC7B,YAAY,GAAG,wCAAwC,CAAC;oBAC5D,YAAY,IAAI,gBAAS,IAAA,iCAAuB,EAAC,eAAe,EAAE,IAAI,CAAC,CAAE,CAAC;oBAE1E,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;oBAEnC,4EAA4E;oBAC5E,8EAA8E;oBAC9E,wEAAwE;oBACxE,qCAAqC;oBACrC,IAAI,KAAK,EAAE;wBACT,gBAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;wBAC3B,MAAM,KAAK,CAAC;qBACb;oBAED,yDAAyD;oBACzD,sBAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC,EAAC;iBAChD;gBAED,sFAAsF;gBACtF,IAAI,KAAK,EAAE;oBACT,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;oBACnC,MAAM,KAAK,CAAC;iBACb;gBAED,kFAAkF;gBAClF,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;gBAElC,sBAAO,GAAG,EAAC;;;KACZ,CAAC"}
|
package/src/v4/http/types.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { JsonMap } from '../../common/jsonTypes';
|
|
3
3
|
import { Path, SpecificationVersion, TemplateHeaders, TemplateQuery, V3MockServer, V3ProviderState, V3Request, V3Response } from '../../v3';
|
|
4
|
-
import { AnyTemplate } from '../../v3/matchers';
|
|
5
4
|
export type V4ProviderState = V3ProviderState;
|
|
6
5
|
export type V4MockServer = V3MockServer;
|
|
7
6
|
export type V4Request = V3Request;
|
|
@@ -57,14 +56,14 @@ export type V4RequestBuilderFunc = (builder: V4RequestBuilder) => void;
|
|
|
57
56
|
export interface V4RequestBuilder {
|
|
58
57
|
query(query: TemplateQuery): V4RequestBuilder;
|
|
59
58
|
headers(headers: TemplateHeaders): V4RequestBuilder;
|
|
60
|
-
jsonBody(body:
|
|
59
|
+
jsonBody(body: unknown): V4RequestBuilder;
|
|
61
60
|
binaryFile(contentType: string, file: string): V4RequestBuilder;
|
|
62
61
|
multipartBody(contentType: string, filename: string, mimePartName: string): V4RequestBuilder;
|
|
63
62
|
body(contentType: string, body: Buffer): V4RequestBuilder;
|
|
64
63
|
}
|
|
65
64
|
export interface V4ResponseBuilder {
|
|
66
65
|
headers(headers: TemplateHeaders): V4ResponseBuilder;
|
|
67
|
-
jsonBody(body:
|
|
66
|
+
jsonBody(body: unknown): V4ResponseBuilder;
|
|
68
67
|
binaryFile(contentType: string, file: string): V4ResponseBuilder;
|
|
69
68
|
multipartBody(contentType: string, filename: string, mimePartName: string): V4ResponseBuilder;
|
|
70
69
|
body(contentType: string, body: Buffer): V4ResponseBuilder;
|
|
@@ -89,7 +88,7 @@ export interface V4InteractionWithPluginRequest {
|
|
|
89
88
|
export interface V4RequestWithPluginBuilder {
|
|
90
89
|
query(query: TemplateQuery): V4RequestWithPluginBuilder;
|
|
91
90
|
headers(headers: TemplateHeaders): V4RequestWithPluginBuilder;
|
|
92
|
-
jsonBody(body:
|
|
91
|
+
jsonBody(body: unknown): V4RequestWithPluginBuilder;
|
|
93
92
|
binaryFile(contentType: string, file: string): V4RequestWithPluginBuilder;
|
|
94
93
|
multipartBody(contentType: string, filename: string, mimePartName: string): V4RequestWithPluginBuilder;
|
|
95
94
|
body(contentType: string, body: Buffer): V4RequestWithPluginBuilder;
|
|
@@ -97,7 +96,7 @@ export interface V4RequestWithPluginBuilder {
|
|
|
97
96
|
}
|
|
98
97
|
export interface V4ResponseWithPluginBuilder {
|
|
99
98
|
headers(headers: TemplateHeaders): V4ResponseBuilder;
|
|
100
|
-
jsonBody(body:
|
|
99
|
+
jsonBody(body: unknown): V4ResponseBuilder;
|
|
101
100
|
binaryFile(contentType: string, file: string): V4ResponseBuilder;
|
|
102
101
|
multipartBody(contentType: string, filename: string, mimePartName: string): V4ResponseBuilder;
|
|
103
102
|
body(contentType: string, body: Buffer): V4ResponseBuilder;
|
package/src/v4/index.js
CHANGED
|
@@ -5,13 +5,15 @@ var pact_core_1 = require("@pact-foundation/pact-core");
|
|
|
5
5
|
var http_1 = require("./http");
|
|
6
6
|
var package_json_1 = require("../../package.json");
|
|
7
7
|
var message_1 = require("./message");
|
|
8
|
+
var v3_1 = require("../v3");
|
|
8
9
|
var PactV4 = /** @class */ (function () {
|
|
9
10
|
function PactV4(opts) {
|
|
11
|
+
var _a;
|
|
10
12
|
this.opts = opts;
|
|
11
13
|
if (!process.env.ENABLE_FEATURE_V4) {
|
|
12
14
|
throw Error("The v4 package is currently in beta and requires the 'ENABLE_FEATURE_V4' environment variable to be set");
|
|
13
15
|
}
|
|
14
|
-
this.pact = (0, pact_core_1.makeConsumerPact)(opts.consumer, opts.provider, opts.spec, opts.logLevel);
|
|
16
|
+
this.pact = (0, pact_core_1.makeConsumerPact)(opts.consumer, opts.provider, (_a = opts.spec) !== null && _a !== void 0 ? _a : v3_1.SpecificationVersion.SPECIFICATION_VERSION_V4, opts.logLevel);
|
|
15
17
|
this.pact.addMetadata('pact-js', 'version', package_json_1.version);
|
|
16
18
|
}
|
|
17
19
|
PactV4.prototype.addInteraction = function () {
|
package/src/v4/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v4/index.ts"],"names":[],"mappings":";;;AAAA,wDAA4E;AAC5E,+BAAiD;AAGjD,mDAAmE;AAEnE,qCAA2D;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v4/index.ts"],"names":[],"mappings":";;;AAAA,wDAA4E;AAC5E,+BAAiD;AAGjD,mDAAmE;AAEnE,qCAA2D;AAC3D,4BAA6C;AAE7C;IAGE,gBAAoB,IAAmB;;QAAnB,SAAI,GAAJ,IAAI,CAAe;QACrC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE;YAClC,MAAM,KAAK,CACT,yGAAyG,CAC1G,CAAC;SACH;QAED,IAAI,CAAC,IAAI,GAAG,IAAA,4BAAgB,EAC1B,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,QAAQ,EACb,MAAA,IAAI,CAAC,IAAI,mCAAI,yBAAoB,CAAC,wBAAwB,EAC1D,IAAI,CAAC,QAAQ,CACd,CAAC;QAEF,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,SAAS,EAAE,sBAAkB,CAAC,CAAC;IAClE,CAAC;IAED,+BAAc,GAAd;QACE,OAAO,IAAI,8BAAuB,CAChC,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC,EAC5B,IAAI,CAAC,IAAI,CACV,CAAC;IACJ,CAAC;IAED,0CAAyB,GAAzB,UACE,WAAmB;QAEnB,OAAO,IAAI,wCAA8B,CACvC,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,WAAW,CAAC,EAC5C,IAAI,CAAC,IAAI,CACV,CAAC;IACJ,CAAC;IACH,aAAC;AAAD,CAAC,AArCD,IAqCC;AArCY,wBAAM"}
|