@seontechnologies/pactjs-utils 1.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/LICENSE +190 -0
- package/README.md +463 -0
- package/dist/cjs/consumer-helpers/create-provider-state.d.ts +18 -0
- package/dist/cjs/consumer-helpers/create-provider-state.d.ts.map +1 -0
- package/dist/cjs/consumer-helpers/create-provider-state.js +18 -0
- package/dist/cjs/consumer-helpers/create-provider-state.js.map +1 -0
- package/dist/cjs/consumer-helpers/index.d.ts +6 -0
- package/dist/cjs/consumer-helpers/index.d.ts.map +1 -0
- package/dist/cjs/consumer-helpers/index.js +11 -0
- package/dist/cjs/consumer-helpers/index.js.map +1 -0
- package/dist/cjs/consumer-helpers/set-json-content.d.ts +32 -0
- package/dist/cjs/consumer-helpers/set-json-content.d.ts.map +1 -0
- package/dist/cjs/consumer-helpers/set-json-content.js +28 -0
- package/dist/cjs/consumer-helpers/set-json-content.js.map +1 -0
- package/dist/cjs/consumer-helpers/to-json-map.d.ts +13 -0
- package/dist/cjs/consumer-helpers/to-json-map.d.ts.map +1 -0
- package/dist/cjs/consumer-helpers/to-json-map.js +34 -0
- package/dist/cjs/consumer-helpers/to-json-map.js.map +1 -0
- package/dist/cjs/index.d.ts +7 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +19 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/pact-types.d.ts +45 -0
- package/dist/cjs/pact-types.d.ts.map +1 -0
- package/dist/cjs/pact-types.js +11 -0
- package/dist/cjs/pact-types.js.map +1 -0
- package/dist/cjs/provider-verifier/build-verifier-options.d.ts +49 -0
- package/dist/cjs/provider-verifier/build-verifier-options.d.ts.map +1 -0
- package/dist/cjs/provider-verifier/build-verifier-options.js +113 -0
- package/dist/cjs/provider-verifier/build-verifier-options.js.map +1 -0
- package/dist/cjs/provider-verifier/handle-url-and-selectors.d.ts +18 -0
- package/dist/cjs/provider-verifier/handle-url-and-selectors.d.ts.map +1 -0
- package/dist/cjs/provider-verifier/handle-url-and-selectors.js +137 -0
- package/dist/cjs/provider-verifier/handle-url-and-selectors.js.map +1 -0
- package/dist/cjs/provider-verifier/index.d.ts +3 -0
- package/dist/cjs/provider-verifier/index.d.ts.map +1 -0
- package/dist/cjs/provider-verifier/index.js +10 -0
- package/dist/cjs/provider-verifier/index.js.map +1 -0
- package/dist/cjs/request-filter/create-request-filter.d.ts +19 -0
- package/dist/cjs/request-filter/create-request-filter.d.ts.map +1 -0
- package/dist/cjs/request-filter/create-request-filter.js +39 -0
- package/dist/cjs/request-filter/create-request-filter.js.map +1 -0
- package/dist/cjs/request-filter/index.d.ts +2 -0
- package/dist/cjs/request-filter/index.d.ts.map +1 -0
- package/dist/cjs/request-filter/index.js +7 -0
- package/dist/cjs/request-filter/index.js.map +1 -0
- package/dist/cjs/zod-to-pact/index.d.ts +2 -0
- package/dist/cjs/zod-to-pact/index.d.ts.map +1 -0
- package/dist/cjs/zod-to-pact/index.js +6 -0
- package/dist/cjs/zod-to-pact/index.js.map +1 -0
- package/dist/cjs/zod-to-pact/zod-to-pact.d.ts +37 -0
- package/dist/cjs/zod-to-pact/zod-to-pact.d.ts.map +1 -0
- package/dist/cjs/zod-to-pact/zod-to-pact.js +151 -0
- package/dist/cjs/zod-to-pact/zod-to-pact.js.map +1 -0
- package/dist/esm/consumer-helpers/create-provider-state.d.ts +18 -0
- package/dist/esm/consumer-helpers/create-provider-state.d.ts.map +1 -0
- package/dist/esm/consumer-helpers/create-provider-state.js +18 -0
- package/dist/esm/consumer-helpers/create-provider-state.js.map +1 -0
- package/dist/esm/consumer-helpers/index.d.ts +6 -0
- package/dist/esm/consumer-helpers/index.d.ts.map +1 -0
- package/dist/esm/consumer-helpers/index.js +11 -0
- package/dist/esm/consumer-helpers/index.js.map +1 -0
- package/dist/esm/consumer-helpers/set-json-content.d.ts +32 -0
- package/dist/esm/consumer-helpers/set-json-content.d.ts.map +1 -0
- package/dist/esm/consumer-helpers/set-json-content.js +28 -0
- package/dist/esm/consumer-helpers/set-json-content.js.map +1 -0
- package/dist/esm/consumer-helpers/to-json-map.d.ts +13 -0
- package/dist/esm/consumer-helpers/to-json-map.d.ts.map +1 -0
- package/dist/esm/consumer-helpers/to-json-map.js +34 -0
- package/dist/esm/consumer-helpers/to-json-map.js.map +1 -0
- package/dist/esm/index.d.ts +7 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +19 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/pact-types.d.ts +45 -0
- package/dist/esm/pact-types.d.ts.map +1 -0
- package/dist/esm/pact-types.js +11 -0
- package/dist/esm/pact-types.js.map +1 -0
- package/dist/esm/provider-verifier/build-verifier-options.d.ts +49 -0
- package/dist/esm/provider-verifier/build-verifier-options.d.ts.map +1 -0
- package/dist/esm/provider-verifier/build-verifier-options.js +113 -0
- package/dist/esm/provider-verifier/build-verifier-options.js.map +1 -0
- package/dist/esm/provider-verifier/handle-url-and-selectors.d.ts +18 -0
- package/dist/esm/provider-verifier/handle-url-and-selectors.d.ts.map +1 -0
- package/dist/esm/provider-verifier/handle-url-and-selectors.js +137 -0
- package/dist/esm/provider-verifier/handle-url-and-selectors.js.map +1 -0
- package/dist/esm/provider-verifier/index.d.ts +3 -0
- package/dist/esm/provider-verifier/index.d.ts.map +1 -0
- package/dist/esm/provider-verifier/index.js +10 -0
- package/dist/esm/provider-verifier/index.js.map +1 -0
- package/dist/esm/request-filter/create-request-filter.d.ts +19 -0
- package/dist/esm/request-filter/create-request-filter.d.ts.map +1 -0
- package/dist/esm/request-filter/create-request-filter.js +39 -0
- package/dist/esm/request-filter/create-request-filter.js.map +1 -0
- package/dist/esm/request-filter/index.d.ts +2 -0
- package/dist/esm/request-filter/index.d.ts.map +1 -0
- package/dist/esm/request-filter/index.js +7 -0
- package/dist/esm/request-filter/index.js.map +1 -0
- package/dist/esm/zod-to-pact/index.d.ts +2 -0
- package/dist/esm/zod-to-pact/index.d.ts.map +1 -0
- package/dist/esm/zod-to-pact/index.js +6 -0
- package/dist/esm/zod-to-pact/index.js.map +1 -0
- package/dist/esm/zod-to-pact/zod-to-pact.d.ts +37 -0
- package/dist/esm/zod-to-pact/zod-to-pact.d.ts.map +1 -0
- package/dist/esm/zod-to-pact/zod-to-pact.js +151 -0
- package/dist/esm/zod-to-pact/zod-to-pact.js.map +1 -0
- package/dist/types/consumer-helpers/create-provider-state.d.ts +18 -0
- package/dist/types/consumer-helpers/create-provider-state.d.ts.map +1 -0
- package/dist/types/consumer-helpers/index.d.ts +6 -0
- package/dist/types/consumer-helpers/index.d.ts.map +1 -0
- package/dist/types/consumer-helpers/set-json-content.d.ts +32 -0
- package/dist/types/consumer-helpers/set-json-content.d.ts.map +1 -0
- package/dist/types/consumer-helpers/to-json-map.d.ts +13 -0
- package/dist/types/consumer-helpers/to-json-map.d.ts.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/pact-types.d.ts +45 -0
- package/dist/types/pact-types.d.ts.map +1 -0
- package/dist/types/provider-verifier/build-verifier-options.d.ts +49 -0
- package/dist/types/provider-verifier/build-verifier-options.d.ts.map +1 -0
- package/dist/types/provider-verifier/handle-url-and-selectors.d.ts +18 -0
- package/dist/types/provider-verifier/handle-url-and-selectors.d.ts.map +1 -0
- package/dist/types/provider-verifier/index.d.ts +3 -0
- package/dist/types/provider-verifier/index.d.ts.map +1 -0
- package/dist/types/request-filter/create-request-filter.d.ts +19 -0
- package/dist/types/request-filter/create-request-filter.d.ts.map +1 -0
- package/dist/types/request-filter/index.d.ts +2 -0
- package/dist/types/request-filter/index.d.ts.map +1 -0
- package/dist/types/zod-to-pact/index.d.ts +2 -0
- package/dist/types/zod-to-pact/index.d.ts.map +1 -0
- package/dist/types/zod-to-pact/zod-to-pact.d.ts +37 -0
- package/dist/types/zod-to-pact/zod-to-pact.d.ts.map +1 -0
- package/package.json +136 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding any notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2025 SEON Technologies Kft.
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,463 @@
|
|
|
1
|
+
# pactjs-utils
|
|
2
|
+
|
|
3
|
+
A collection of utilities for Pact.js contract testing, designed to eliminate boilerplate and enforce best practices for consumer-driven contract testing.
|
|
4
|
+
|
|
5
|
+
📚 **[View the full documentation on GitHub Pages](https://seontechnologies.github.io/pactjs-utils/)** or browse the [docs folder](./docs)
|
|
6
|
+
|
|
7
|
+
## Table of Contents
|
|
8
|
+
|
|
9
|
+
- [pactjs-utils](#pactjs-utils)
|
|
10
|
+
- [Table of Contents](#table-of-contents)
|
|
11
|
+
- [Why This Library](#why-this-library)
|
|
12
|
+
- [Quick Start](#quick-start)
|
|
13
|
+
- [Consumer: Creating provider states with typed params](#consumer-creating-provider-states-with-typed-params)
|
|
14
|
+
- [Provider: Building verifier options with one call](#provider-building-verifier-options-with-one-call)
|
|
15
|
+
- [Auth: Injecting request filters](#auth-injecting-request-filters)
|
|
16
|
+
- [Message/Kafka provider verification](#messagekafka-provider-verification)
|
|
17
|
+
- [Installation](#installation)
|
|
18
|
+
- [Utilities](#utilities)
|
|
19
|
+
- [Pact Testing Types](#pact-testing-types)
|
|
20
|
+
- [Pact folder structure](#pact-folder-structure)
|
|
21
|
+
- [Contract Testing Flows](#contract-testing-flows)
|
|
22
|
+
- [Local Flow (no Pact Broker)](#local-flow-no-pact-broker)
|
|
23
|
+
- [Remote Flow (with Pact Broker)](#remote-flow-with-pact-broker)
|
|
24
|
+
- [Provider-Driven Flow (Bi-Directional / BDCT)](#provider-driven-flow-bi-directional--bdct)
|
|
25
|
+
- [CI Workflows](#ci-workflows)
|
|
26
|
+
- [Testing](#testing)
|
|
27
|
+
- [Development](#development)
|
|
28
|
+
- [Module Format Support](#module-format-support)
|
|
29
|
+
- [Testing the Package Locally](#testing-the-package-locally)
|
|
30
|
+
- [Release and Publishing](#release-and-publishing)
|
|
31
|
+
- [Publishing via GitHub UI (Recommended)](#publishing-via-github-ui-recommended)
|
|
32
|
+
- [Publishing Locally](#publishing-locally)
|
|
33
|
+
- [Contributing](#contributing)
|
|
34
|
+
- [License](#license)
|
|
35
|
+
|
|
36
|
+
## Why This Library
|
|
37
|
+
|
|
38
|
+
Pact.js is powerful but that power may come with friction for some teams. This library removes the repetitive parts so you can focus on writing contracts, not plumbing.
|
|
39
|
+
|
|
40
|
+
- **JsonMap conversion headaches** -- Pact expects `JsonMap` for provider state params, but your code uses typed objects. `createProviderState` and `toJsonMap` handle the conversion so you never think about it.
|
|
41
|
+
- **Express middleware type gymnastics** -- Injecting auth tokens into Pact verification requests requires wrestling with Express request/response types. `createRequestFilter` wraps this into a single call with a pluggable token generator.
|
|
42
|
+
- **Scattered verifier configuration** -- Building `VerifierOptions` means assembling broker URLs, consumer selectors, state handlers, request filters, and version tags from multiple sources. `buildVerifierOptions` and `buildMessageVerifierOptions` consolidate this into one configuration object.
|
|
43
|
+
- **Cross-execution bugs in CI** -- When multiple provider-consumer pairs share a CI pipeline, getting consumer version selectors, breaking change flags, and webhook payloads right is error-prone. `handlePactBrokerUrlAndSelectors` reads environment variables and assembles the correct selector strategy automatically.
|
|
44
|
+
|
|
45
|
+
## Quick Start
|
|
46
|
+
|
|
47
|
+
### Consumer: Creating provider states with typed params
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
// pact/http/consumer/movies-read.pacttest.ts
|
|
51
|
+
import { createProviderState } from '@seontechnologies/pactjs-utils'
|
|
52
|
+
|
|
53
|
+
// Instead of manually converting to JsonMap:
|
|
54
|
+
const state = createProviderState({
|
|
55
|
+
name: 'Has a movie with a specific ID',
|
|
56
|
+
params: { id: 1, name: 'Inception', year: 2010 }
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
// Use with pact.addInteraction().given():
|
|
60
|
+
await pact.addInteraction().given(...state)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Provider: Building verifier options with one call
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
// pact/http/provider/provider-contract.pacttest.ts
|
|
67
|
+
import { buildVerifierOptions } from '@seontechnologies/pactjs-utils'
|
|
68
|
+
|
|
69
|
+
const options = buildVerifierOptions({
|
|
70
|
+
provider: 'SampleMoviesAPI',
|
|
71
|
+
port: '3001',
|
|
72
|
+
stateHandlers,
|
|
73
|
+
includeMainAndDeployed: process.env.PACT_BREAKING_CHANGE !== 'true',
|
|
74
|
+
requestFilter: createRequestFilter({
|
|
75
|
+
tokenGenerator: () => generateAuthToken({ userIdentifier: 'admin' })
|
|
76
|
+
})
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
const verifier = new Verifier(options)
|
|
80
|
+
await verifier.verifyProvider()
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Auth: Injecting request filters
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
// pact/http/helpers/pact-helpers.ts
|
|
87
|
+
import { createRequestFilter } from '@seontechnologies/pactjs-utils'
|
|
88
|
+
|
|
89
|
+
// Custom token generator
|
|
90
|
+
const filter = createRequestFilter({
|
|
91
|
+
tokenGenerator: () =>
|
|
92
|
+
`${new Date().toISOString()}:${JSON.stringify({ userId: 'admin' })}`
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
// Default (ISO timestamp token)
|
|
96
|
+
const defaultFilter = createRequestFilter()
|
|
97
|
+
|
|
98
|
+
// No auth needed
|
|
99
|
+
import { noOpRequestFilter } from '@seontechnologies/pactjs-utils'
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Message/Kafka provider verification
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
// pact/message/provider/provider-message-queue.pacttest.ts
|
|
106
|
+
import { buildMessageVerifierOptions } from '@seontechnologies/pactjs-utils'
|
|
107
|
+
|
|
108
|
+
const options = buildMessageVerifierOptions({
|
|
109
|
+
provider: 'SampleMoviesAPI-event-producer',
|
|
110
|
+
messageProviders,
|
|
111
|
+
stateHandlers,
|
|
112
|
+
includeMainAndDeployed: true
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
const messagePact = new MessageProviderPact(options)
|
|
116
|
+
await messagePact.verify()
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Installation
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
npm i -D @seontechnologies/pactjs-utils
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
> **Note:** This package requires `@pact-foundation/pact >= 16.2.0` as a peer dependency.
|
|
126
|
+
|
|
127
|
+
## Utilities
|
|
128
|
+
|
|
129
|
+
| Category | Utilities | Docs |
|
|
130
|
+
| ------------ | ------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------- |
|
|
131
|
+
| **Consumer** | `toJsonMap`, `createProviderState` | [Consumer Helpers](https://seontechnologies.github.io/pactjs-utils/consumer-helpers) |
|
|
132
|
+
| **Schema** | `zodToPactMatchers` | [Zod to Pact](https://seontechnologies.github.io/pactjs-utils/zod-to-pact/) |
|
|
133
|
+
| **Provider** | `buildVerifierOptions`, `buildMessageVerifierOptions`, `handlePactBrokerUrlAndSelectors`, `getProviderVersionTags` | [Provider Verifier](https://seontechnologies.github.io/pactjs-utils/provider-verifier) |
|
|
134
|
+
| **Auth** | `createRequestFilter`, `noOpRequestFilter` | [Request Filter](https://seontechnologies.github.io/pactjs-utils/request-filter) |
|
|
135
|
+
|
|
136
|
+
## Pact Testing Types
|
|
137
|
+
|
|
138
|
+
Pact supports three types of contract testing. This project implements all three:
|
|
139
|
+
|
|
140
|
+
| Type | Status | Cost | Local | Directory |
|
|
141
|
+
| ------------------------------------ | ----------- | ------------ | ----- | ---------------- |
|
|
142
|
+
| **Consumer-Driven (HTTP)** | Implemented | **Free** | Yes | `pact/http/` |
|
|
143
|
+
| **Message Queue (Kafka/async)** | Implemented | **Free** | Yes | `pact/message/` |
|
|
144
|
+
| **Bi-Directional (provider-driven)** | Implemented | PactFlow req | No | `scripts/` (OAS) |
|
|
145
|
+
|
|
146
|
+
**Consumer-Driven Contract Testing (CDCT)** -- The consumer defines HTTP interaction expectations, generates pact files, and the provider verifies against them. This is the core Pact workflow. Supports both local and broker modes. (`pact/http/consumer/` for consumer tests, `pact/http/provider/` for provider verification)
|
|
147
|
+
|
|
148
|
+
**Message Queue Testing** -- The same consumer-driven approach applied to async messaging (Kafka, SQS, etc.). The consumer defines message expectations, and the provider verifies it can produce matching messages using `MessageProviderPact`. Supports both local and broker modes. (`pact/message/consumer/` for consumer tests, `pact/message/provider/` for provider verification)
|
|
149
|
+
|
|
150
|
+
**Bi-Directional Contract Testing (BDCT)** -- The provider publishes an auto-generated OpenAPI spec to PactFlow, which cross-validates it against consumer pacts. No local mode -- requires PactFlow to perform the cross-validation. The provider's own tests (unit/integration) serve as the verification evidence. (`scripts/publish-provider-contract.sh`)
|
|
151
|
+
|
|
152
|
+
### Pact folder structure
|
|
153
|
+
|
|
154
|
+
```text
|
|
155
|
+
pact/
|
|
156
|
+
http/ # HTTP contract tests (CDCT)
|
|
157
|
+
consumer/ # Consumer-driven HTTP expectations
|
|
158
|
+
movies-read.pacttest.ts # GET operations
|
|
159
|
+
movies-write.pacttest.ts # POST/PUT/DELETE operations
|
|
160
|
+
provider/ # HTTP provider verification
|
|
161
|
+
provider-contract.pacttest.ts # Verification (local + broker)
|
|
162
|
+
helpers/ # HTTP-specific helpers
|
|
163
|
+
pact-helpers.ts # Auth token generation
|
|
164
|
+
state-handlers.ts # Provider state setup (DB seeding)
|
|
165
|
+
vitest.consumer.config.mts # HTTP consumer test config
|
|
166
|
+
vitest.provider.config.mts # HTTP provider test config
|
|
167
|
+
message/ # Message queue contract tests (Kafka/async)
|
|
168
|
+
consumer/ # Consumer-side message expectations
|
|
169
|
+
movie-events.pacttest.ts # Movie event message expectations
|
|
170
|
+
provider/ # Message provider verification
|
|
171
|
+
provider-message-queue.pacttest.ts # Verification (local + broker)
|
|
172
|
+
helpers/ # Message-specific helpers
|
|
173
|
+
message-providers.ts # Kafka message producers
|
|
174
|
+
state-handlers.ts # Re-exports HTTP state handlers
|
|
175
|
+
vitest.consumer.config.mts # Message consumer test config
|
|
176
|
+
vitest.provider.config.mts # Message provider test config
|
|
177
|
+
|
|
178
|
+
scripts/
|
|
179
|
+
publish-provider-contract.sh # Bi-directional: publish OAS to PactFlow (PAID)
|
|
180
|
+
|
|
181
|
+
sample-app/backend/src/api-docs/
|
|
182
|
+
openapi.json # Auto-generated OpenAPI 3.1.0 spec (from Zod schemas)
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Contract Testing Flows
|
|
186
|
+
|
|
187
|
+
There are three flows: **local** (no broker, for development), **remote** (with Pact Broker, for CI/CD), and **provider-driven** (bi-directional, publishes OAS to PactFlow).
|
|
188
|
+
|
|
189
|
+
### Local Flow (no Pact Broker)
|
|
190
|
+
|
|
191
|
+
The local flow is self-contained. This can be used in monorepos, similar to the repo where the sample front & backe ends coexist. The consumer generates pact files, and the provider verifies directly against those local files. No broker, no network, no environment variables needed.
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
# 1. Run consumer pact tests — generates pact JSON files in pacts/
|
|
195
|
+
npm run test:pact:consumer
|
|
196
|
+
|
|
197
|
+
# 2. Run provider verification against local pact files
|
|
198
|
+
npm run test:pact:provider:local # Verify CDCT+MQ locally
|
|
199
|
+
npm run test:pact:provider:local:contract # (optional - only execute CDCT)
|
|
200
|
+
npm run test:pact:provider:local:message # (optional - only execute message queue)
|
|
201
|
+
|
|
202
|
+
# Or run both in sequence:
|
|
203
|
+
npm run test:pact:local
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
The provider reads the pact files from the `pacts/` directory using `pactUrls` instead of pulling from a broker. This is the fastest way to iterate during development.
|
|
207
|
+
|
|
208
|
+
### Remote Flow (with Pact Broker)
|
|
209
|
+
|
|
210
|
+
The remote flow uses a [Pact Broker](https://docs.pact.io/pact_broker) (e.g. [PactFlow](https://pactflow.io/)) to coordinate contracts between repositories. This is how contract testing works in CI/CD with separate consumer and provider repos.
|
|
211
|
+
|
|
212
|
+
**Setup:** Create a `.env` file (see `.env.example`):
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
PACT_BROKER_TOKEN=your_token_here
|
|
216
|
+
PACT_BROKER_BASE_URL=https://your-org.pactflow.io
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
**Consumer flow:**
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
npm run test:pact:consumer # (1) Generate pact files
|
|
223
|
+
|
|
224
|
+
# commit before publishing — publish tags the version with GITHUB_SHA
|
|
225
|
+
npm run publish:pact # (2) Publish to broker
|
|
226
|
+
|
|
227
|
+
npm run can:i:deploy:consumer # (4) Check deployment safety
|
|
228
|
+
|
|
229
|
+
# only on main:
|
|
230
|
+
npm run record:consumer:deployment # (5) Record deployment to environment
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
**Provider flow:**
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
npm run test:pact:provider:remote # (3) Verify CDCT+MQ against broker (triggered by webhook)
|
|
237
|
+
npm run test:pact:provider:remote:contract # (optional - only execute CDCT)
|
|
238
|
+
npm run test:pact:provider:remote:message # (optional - only execute message queue)
|
|
239
|
+
|
|
240
|
+
npm run can:i:deploy:provider # (4) Check deployment safety
|
|
241
|
+
|
|
242
|
+
# only on main:
|
|
243
|
+
npm run record:provider:deployment # (5) Record deployment to environment
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
The key coordination: when there are separate repos, the provider must run verification `(3)` after the consumer publishes `(2)` but before the consumer can check `can-i-deploy (4)`. **Webhooks** automate this trigger -- when the consumer publishes a new pact, the broker fires a webhook that triggers the provider's CI to run verification.
|
|
247
|
+
|
|
248
|
+
```mermaid
|
|
249
|
+
sequenceDiagram
|
|
250
|
+
participant C as Consumer Repo
|
|
251
|
+
participant B as Pact Broker
|
|
252
|
+
participant P as Provider Repo
|
|
253
|
+
|
|
254
|
+
C->>C: test:pact:consumer
|
|
255
|
+
C->>C: git commit
|
|
256
|
+
C->>B: publish:pact
|
|
257
|
+
Note right of B: Stores contract
|
|
258
|
+
|
|
259
|
+
B-->>P: Webhook: contract_requiring_verification_published\n(PACT_PAYLOAD_URL)
|
|
260
|
+
P->>P: test:pact:provider:remote
|
|
261
|
+
|
|
262
|
+
C->>B: can:i:deploy:consumer
|
|
263
|
+
P->>B: can:i:deploy:provider
|
|
264
|
+
|
|
265
|
+
C->>B: record:consumer:deployment
|
|
266
|
+
P->>B: record:provider:deployment
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
**Environment variables used in remote flow:**
|
|
270
|
+
|
|
271
|
+
| Variable | Purpose | Default |
|
|
272
|
+
| ---------------------- | -------------------------------------------- | ----------- |
|
|
273
|
+
| `PACT_BROKER_BASE_URL` | Pact Broker URL | (required) |
|
|
274
|
+
| `PACT_BROKER_TOKEN` | Auth token for broker | (required) |
|
|
275
|
+
| `GITHUB_SHA` | Provider/consumer version (commit hash) | `'unknown'` |
|
|
276
|
+
| `GITHUB_BRANCH` | Provider version branch | `'main'` |
|
|
277
|
+
| `PACT_PAYLOAD_URL` | Direct pact URL (set by webhooks) | --- |
|
|
278
|
+
| `PACT_BREAKING_CHANGE` | Skip mainBranch/deployedOrReleased selectors | `'false'` |
|
|
279
|
+
|
|
280
|
+
**Consumer version selectors** (controlled by `includeMainAndDeployed` param):
|
|
281
|
+
|
|
282
|
+
| Selector | When included | Purpose |
|
|
283
|
+
| -------------------- | ------------------------ | ------------------------------------------------- |
|
|
284
|
+
| `matchingBranch` | Always | Verify against consumer's matching feature branch |
|
|
285
|
+
| `mainBranch` | `includeMainAndDeployed` | Verify against consumer's main branch |
|
|
286
|
+
| `deployedOrReleased` | `includeMainAndDeployed` | Verify against consumer's deployed versions |
|
|
287
|
+
|
|
288
|
+
**Breaking changes:** When the provider introduces a breaking change, set `includeMainAndDeployed: false` (or `PACT_BREAKING_CHANGE=true` in CI) to only verify against matching branches. This prevents failures from incompatible `mainBranch` or `deployedOrReleased` consumer versions while coordinated PRs are in flight.
|
|
289
|
+
|
|
290
|
+
```bash
|
|
291
|
+
# Provider PR with breaking change:
|
|
292
|
+
PACT_BREAKING_CHANGE=true npm run test:pact:provider:remote
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### Provider-Driven Flow (Bi-Directional / BDCT)
|
|
296
|
+
|
|
297
|
+
Bi-directional contract testing flips the model: instead of running the Pact verifier against a live provider, **both sides publish independently** to PactFlow, which cross-validates the consumer pacts against the provider's OpenAPI spec.
|
|
298
|
+
|
|
299
|
+
> **No local mode.** BDCT requires PactFlow to perform the cross-validation -- there is no way to run this locally. The consumer-driven flow covers local development needs.
|
|
300
|
+
|
|
301
|
+
**Consumer flow:**
|
|
302
|
+
|
|
303
|
+
```bash
|
|
304
|
+
npm run test:pact:consumer # (1) Generate pact files
|
|
305
|
+
# commit before publishing — publish tags the version with GITHUB_SHA
|
|
306
|
+
npm run publish:pact # (2) Publish consumer pacts to PactFlow
|
|
307
|
+
|
|
308
|
+
npm run can:i:deploy:consumer # (4) Check deployment safety
|
|
309
|
+
|
|
310
|
+
# only on main:
|
|
311
|
+
npm run record:consumer:deployment # (5) Record deployment to environment
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
**Provider flow:**
|
|
315
|
+
|
|
316
|
+
```bash
|
|
317
|
+
npm run publish:provider:contract # (3) Generate OAS, run tests, publish to PactFlow
|
|
318
|
+
|
|
319
|
+
npm run can:i:deploy:provider # (4) Check deployment safety
|
|
320
|
+
|
|
321
|
+
# only on main:
|
|
322
|
+
npm run record:provider:deployment # (5) Record deployment to environment
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
The key difference from CDCT: step `(3)` publishes the provider's OpenAPI spec instead of running the Pact verifier against a live provider. PactFlow cross-validates the consumer pacts against the OAS automatically -- no webhooks needed. Both sides can publish independently.
|
|
326
|
+
|
|
327
|
+
What `publish:provider:contract` does under the hood in this sample repo:
|
|
328
|
+
|
|
329
|
+
1. Generates a fresh OpenAPI spec from Zod schemas (`openapi.json`)
|
|
330
|
+
2. Runs `npm run test:backend` and captures the exit code (usually this would be an api e2e suite that does e2e + schema validation, ensuring that the OpenAPI spec is flawless per actual network data)
|
|
331
|
+
3. Publishes the OAS + verification results via `pactflow publish-provider-contract`
|
|
332
|
+
|
|
333
|
+
## CI Workflows
|
|
334
|
+
|
|
335
|
+
Each workflow is a standalone file that can be copied to its own repo. The monorepo only matters for local development (`npm run test:pact:local`).
|
|
336
|
+
|
|
337
|
+
| Workflow | Repo | Trigger | Purpose |
|
|
338
|
+
| ------------------------------------ | -------- | --------------------- | --------------------------------------- |
|
|
339
|
+
| `contract-test-consumer.yml` | Consumer | PR + push to main | Generate pacts, publish, can-i-deploy |
|
|
340
|
+
| `contract-test-provider.yml` | Provider | PR + push to main | Verify HTTP pacts, can-i-deploy |
|
|
341
|
+
| `contract-test-provider-message.yml` | Provider | PR + push to main | Verify message pacts, can-i-deploy |
|
|
342
|
+
| `contract-test-webhook.yml` | Provider | PactFlow webhook | Verify when consumer publishes new pact |
|
|
343
|
+
| `contract-test-publish-openapi.yml` | Provider | Push to main + manual | Publish OAS to PactFlow (BDCT) |
|
|
344
|
+
| `contract-test-local.yml` | Monorepo | PR + manual | Local consumer + provider (no broker) |
|
|
345
|
+
|
|
346
|
+
**Breaking change detection:** All workflows parse the PR description for a `[x] Pact breaking change` checkbox. When checked, `can-i-deploy` is skipped and provider verification only runs against matching branches. Add the checkbox via the PR template (`.github/PULL_REQUEST_TEMPLATE.md`).
|
|
347
|
+
|
|
348
|
+
**Webhook setup (one-time):** PactFlow must be configured to fire a GitHub `repository_dispatch` event when a consumer publishes a new pact. This triggers `contract-test-webhook.yml` in the provider repo. You can either:
|
|
349
|
+
|
|
350
|
+
1. Create the webhook manually in PactFlow UI (Settings > Webhooks) — see [`scripts/one-time-scripts/create-pact-webhook.sh`](scripts/one-time-scripts/create-pact-webhook.sh) for the exact field values
|
|
351
|
+
2. Run the script directly with the `pact-broker` CLI after filling in your tokens
|
|
352
|
+
|
|
353
|
+
Both approaches require a GitHub PAT with `public_repo` scope, stored as a PactFlow secret named `githubToken`. Use [`scripts/one-time-scripts/create-github-issue-test.sh`](scripts/one-time-scripts/create-github-issue-test.sh) to verify your PAT works before creating the webhook.
|
|
354
|
+
|
|
355
|
+
**Required GitHub secrets:**
|
|
356
|
+
|
|
357
|
+
| Secret | Purpose |
|
|
358
|
+
| ---------------------- | ------------------- |
|
|
359
|
+
| `PACT_BROKER_BASE_URL` | PactFlow broker URL |
|
|
360
|
+
| `PACT_BROKER_TOKEN` | PactFlow API token |
|
|
361
|
+
|
|
362
|
+
## Testing
|
|
363
|
+
|
|
364
|
+
```bash
|
|
365
|
+
npm run test:lib # library unit tests (vitest)
|
|
366
|
+
npm run test:backend # sample-app backend tests
|
|
367
|
+
npm run test:frontend # sample-app frontend tests
|
|
368
|
+
|
|
369
|
+
npm run test:pact:consumer # all consumer contract tests (HTTP + message)
|
|
370
|
+
npm run test:pact:consumer:http # consumer HTTP contract tests
|
|
371
|
+
npm run test:pact:consumer:message # consumer message contract tests
|
|
372
|
+
|
|
373
|
+
npm run test:pact:provider:local # provider CDCT+MQ verification (local)
|
|
374
|
+
npm run test:pact:provider:local:contract # provider CDCT verification (local)
|
|
375
|
+
npm run test:pact:provider:local:message # provider message verification (local)
|
|
376
|
+
|
|
377
|
+
npm run test:pact:local # full local flow (consumer + provider)
|
|
378
|
+
|
|
379
|
+
npm run test:pact:provider:remote # provider CDCT+MQ verification (broker)
|
|
380
|
+
npm run test:pact:provider:remote:contract # provider CDCT verification (broker)
|
|
381
|
+
npm run test:pact:provider:remote:message # provider message verification (broker)
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
## Development
|
|
385
|
+
|
|
386
|
+
```bash
|
|
387
|
+
nvm use
|
|
388
|
+
npm install
|
|
389
|
+
npm run validate # typecheck + lint + test + format
|
|
390
|
+
|
|
391
|
+
npm run test:lib # library unit tests
|
|
392
|
+
npm run test:backend # sample-app backend tests
|
|
393
|
+
npm run test:frontend # sample-app frontend tests
|
|
394
|
+
npm run build # CJS + ESM + types
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
## Module Format Support
|
|
398
|
+
|
|
399
|
+
This package supports both CommonJS and ES Modules:
|
|
400
|
+
|
|
401
|
+
```typescript
|
|
402
|
+
// Works in both CJS and ESM
|
|
403
|
+
import { buildVerifierOptions } from '@seontechnologies/pactjs-utils'
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
## Testing the Package Locally
|
|
407
|
+
|
|
408
|
+
```bash
|
|
409
|
+
# Build the package
|
|
410
|
+
npm run build
|
|
411
|
+
|
|
412
|
+
# Create a tarball package
|
|
413
|
+
npm pack
|
|
414
|
+
|
|
415
|
+
# Install in a target repository (change the version according to the file name)
|
|
416
|
+
# For npm projects:
|
|
417
|
+
npm install ../playwright-utils/seontechnologies-playwright-utils-1.0.1.tgz
|
|
418
|
+
|
|
419
|
+
# For pnpm projects:
|
|
420
|
+
pnpm add file:/path/to/playwright-utils-1.0.1.tgz
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
## Release and Publishing
|
|
424
|
+
|
|
425
|
+
This package is published to the public npm registry under the `@seontechnologies` scope.
|
|
426
|
+
|
|
427
|
+
### Publishing via GitHub UI (Recommended)
|
|
428
|
+
|
|
429
|
+
You can trigger a release directly from GitHub's web interface:
|
|
430
|
+
|
|
431
|
+
1. Go to the repository → Actions → "Publish Package" workflow
|
|
432
|
+
2. Click "Run workflow" button (dropdown on the right)
|
|
433
|
+
3. Select options in the form:
|
|
434
|
+
- **Branch**: main
|
|
435
|
+
- **Version type**: patch/minor/major/custom
|
|
436
|
+
- **Custom version**: Only needed if you selected "custom" type
|
|
437
|
+
4. Click "Run workflow"
|
|
438
|
+
|
|
439
|
+
**Important**:
|
|
440
|
+
|
|
441
|
+
- Requires `NPM_TOKEN` secret to be configured in GitHub repository settings
|
|
442
|
+
- You must review and merge the PR to complete the process
|
|
443
|
+
|
|
444
|
+
### Publishing Locally
|
|
445
|
+
|
|
446
|
+
You can also publish the package locally using the provided script:
|
|
447
|
+
|
|
448
|
+
```bash
|
|
449
|
+
# 1. Set your npm token as an environment variable
|
|
450
|
+
# Get your token from: https://www.npmjs.com/settings/~/tokens
|
|
451
|
+
export NPM_TOKEN=your_npm_token
|
|
452
|
+
|
|
453
|
+
# 2. Run the publish script
|
|
454
|
+
npm run publish:local
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
## Contributing
|
|
458
|
+
|
|
459
|
+
See [CONTRIBUTING.md](./CONTRIBUTING.md) for setup, development workflow, and pull request guidelines.
|
|
460
|
+
|
|
461
|
+
## License
|
|
462
|
+
|
|
463
|
+
Licensed under the terms of the [LICENSE](./LICENSE) file.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { JsonMap } from '../pact-types';
|
|
2
|
+
export type ProviderStateInput = {
|
|
3
|
+
name: string;
|
|
4
|
+
params: Record<string, unknown>;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Creates a tuple representing a provider state for use with Pact.
|
|
8
|
+
* Converts the parameters into a JsonMap where all values are Pact-compatible.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const state = createProviderState({
|
|
12
|
+
* name: 'An existing movie exists',
|
|
13
|
+
* params: { name: 'Inception', year: 2010 }
|
|
14
|
+
* })
|
|
15
|
+
* provider.given(...state)
|
|
16
|
+
*/
|
|
17
|
+
export declare const createProviderState: ({ name, params }: ProviderStateInput) => [string, JsonMap];
|
|
18
|
+
//# sourceMappingURL=create-provider-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-provider-state.d.ts","sourceRoot":"","sources":["../../../src/consumer-helpers/create-provider-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAG5C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAChC,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB,GAAI,kBAGjC,kBAAkB,KAAG,CAAC,MAAM,EAAE,OAAO,CAA8B,CAAA"}
|