codeceptjs 3.6.7 → 4.0.0-beta.2

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.
Files changed (149) hide show
  1. package/bin/codecept.js +81 -84
  2. package/lib/actor.js +13 -13
  3. package/lib/ai.js +13 -10
  4. package/lib/assert/empty.js +21 -20
  5. package/lib/assert/equal.js +39 -37
  6. package/lib/assert/error.js +14 -14
  7. package/lib/assert/include.js +47 -46
  8. package/lib/assert/throws.js +11 -13
  9. package/lib/assert/truth.js +22 -19
  10. package/lib/assert.js +2 -4
  11. package/lib/cli.js +49 -57
  12. package/lib/codecept.js +155 -142
  13. package/lib/colorUtils.js +3 -3
  14. package/lib/command/configMigrate.js +52 -58
  15. package/lib/command/definitions.js +89 -88
  16. package/lib/command/dryRun.js +68 -71
  17. package/lib/command/generate.js +188 -197
  18. package/lib/command/gherkin/init.js +16 -27
  19. package/lib/command/gherkin/snippets.js +20 -20
  20. package/lib/command/gherkin/steps.js +8 -8
  21. package/lib/command/info.js +38 -40
  22. package/lib/command/init.js +288 -290
  23. package/lib/command/interactive.js +32 -32
  24. package/lib/command/list.js +26 -26
  25. package/lib/command/run-multiple/chunk.js +5 -5
  26. package/lib/command/run-multiple/collection.js +3 -3
  27. package/lib/command/run-multiple/run.js +2 -6
  28. package/lib/command/run-multiple.js +93 -113
  29. package/lib/command/run-rerun.js +25 -20
  30. package/lib/command/run-workers.js +66 -64
  31. package/lib/command/run.js +29 -26
  32. package/lib/command/utils.js +65 -80
  33. package/lib/command/workers/runTests.js +10 -10
  34. package/lib/config.js +9 -10
  35. package/lib/container.js +48 -40
  36. package/lib/data/context.js +59 -60
  37. package/lib/data/dataScenarioConfig.js +47 -47
  38. package/lib/data/dataTableArgument.js +29 -29
  39. package/lib/data/table.js +20 -26
  40. package/lib/dirname.js +5 -0
  41. package/lib/event.js +167 -163
  42. package/lib/heal.js +17 -13
  43. package/lib/helper/AI.js +41 -130
  44. package/lib/helper/ApiDataFactory.js +69 -73
  45. package/lib/helper/Appium.js +381 -412
  46. package/lib/helper/Expect.js +425 -0
  47. package/lib/helper/ExpectHelper.js +48 -40
  48. package/lib/helper/FileSystem.js +79 -80
  49. package/lib/helper/GraphQL.js +43 -44
  50. package/lib/helper/GraphQLDataFactory.js +50 -50
  51. package/lib/helper/JSONResponse.js +62 -65
  52. package/lib/helper/Mochawesome.js +28 -28
  53. package/lib/helper/MockServer.js +14 -12
  54. package/lib/helper/Nightmare.js +566 -662
  55. package/lib/helper/Playwright.js +1216 -1361
  56. package/lib/helper/Protractor.js +627 -663
  57. package/lib/helper/Puppeteer.js +1128 -1231
  58. package/lib/helper/REST.js +68 -159
  59. package/lib/helper/SoftExpectHelper.js +2 -2
  60. package/lib/helper/TestCafe.js +484 -490
  61. package/lib/helper/WebDriver.js +1156 -1297
  62. package/lib/helper/clientscripts/PollyWebDriverExt.js +1 -1
  63. package/lib/helper/errors/ConnectionRefused.js +1 -1
  64. package/lib/helper/errors/ElementAssertion.js +2 -2
  65. package/lib/helper/errors/ElementNotFound.js +2 -2
  66. package/lib/helper/errors/RemoteBrowserConnectionRefused.js +1 -1
  67. package/lib/helper/extras/Console.js +1 -1
  68. package/lib/helper/extras/PlaywrightPropEngine.js +2 -2
  69. package/lib/helper/extras/PlaywrightReactVueLocator.js +1 -1
  70. package/lib/helper/extras/PlaywrightRestartOpts.js +18 -21
  71. package/lib/helper/extras/Popup.js +1 -1
  72. package/lib/helper/extras/React.js +3 -3
  73. package/lib/helper/network/actions.js +7 -14
  74. package/lib/helper/network/utils.js +2 -3
  75. package/lib/helper/scripts/blurElement.js +1 -1
  76. package/lib/helper/scripts/focusElement.js +1 -1
  77. package/lib/helper/scripts/highlightElement.js +1 -1
  78. package/lib/helper/scripts/isElementClickable.js +1 -1
  79. package/lib/helper/testcafe/testControllerHolder.js +1 -1
  80. package/lib/helper/testcafe/testcafe-utils.js +7 -6
  81. package/lib/helper.js +3 -1
  82. package/lib/history.js +5 -6
  83. package/lib/hooks.js +6 -6
  84. package/lib/html.js +7 -7
  85. package/lib/index.js +41 -25
  86. package/lib/interfaces/bdd.js +64 -47
  87. package/lib/interfaces/featureConfig.js +19 -19
  88. package/lib/interfaces/gherkin.js +118 -124
  89. package/lib/interfaces/scenarioConfig.js +29 -29
  90. package/lib/listener/artifacts.js +9 -9
  91. package/lib/listener/config.js +24 -24
  92. package/lib/listener/exit.js +12 -12
  93. package/lib/listener/helpers.js +42 -42
  94. package/lib/listener/mocha.js +11 -11
  95. package/lib/listener/retry.js +30 -32
  96. package/lib/listener/steps.js +53 -50
  97. package/lib/listener/timeout.js +54 -54
  98. package/lib/locator.js +10 -6
  99. package/lib/mochaFactory.js +15 -18
  100. package/lib/output.js +10 -6
  101. package/lib/parser.js +12 -15
  102. package/lib/pause.js +33 -40
  103. package/lib/plugin/allure.js +15 -15
  104. package/lib/plugin/autoDelay.js +37 -29
  105. package/lib/plugin/autoLogin.js +65 -70
  106. package/lib/plugin/commentStep.js +18 -18
  107. package/lib/plugin/coverage.js +67 -115
  108. package/lib/plugin/customLocator.js +20 -21
  109. package/lib/plugin/debugErrors.js +24 -24
  110. package/lib/plugin/eachElement.js +38 -38
  111. package/lib/plugin/fakerTransform.js +6 -6
  112. package/lib/plugin/heal.js +108 -67
  113. package/lib/plugin/pauseOnFail.js +11 -11
  114. package/lib/plugin/retryFailedStep.js +39 -32
  115. package/lib/plugin/retryTo.js +40 -46
  116. package/lib/plugin/screenshotOnFail.js +87 -109
  117. package/lib/plugin/selenoid.js +118 -131
  118. package/lib/plugin/standardActingHelpers.js +8 -2
  119. package/lib/plugin/stepByStepReport.js +91 -110
  120. package/lib/plugin/stepTimeout.js +23 -24
  121. package/lib/plugin/subtitles.js +35 -34
  122. package/lib/plugin/tryTo.js +30 -40
  123. package/lib/plugin/wdio.js +75 -78
  124. package/lib/recorder.js +17 -14
  125. package/lib/rerun.js +10 -11
  126. package/lib/scenario.js +23 -25
  127. package/lib/secret.js +2 -4
  128. package/lib/session.js +10 -10
  129. package/lib/step.js +9 -12
  130. package/lib/store.js +3 -2
  131. package/lib/transform.js +1 -1
  132. package/lib/translation.js +8 -7
  133. package/lib/ui.js +14 -12
  134. package/lib/utils.js +72 -70
  135. package/lib/within.js +10 -10
  136. package/lib/workerStorage.js +25 -27
  137. package/lib/workers.js +32 -29
  138. package/package.json +53 -51
  139. package/translations/de-DE.js +1 -1
  140. package/translations/fr-FR.js +1 -1
  141. package/translations/index.js +13 -9
  142. package/translations/it-IT.js +1 -1
  143. package/translations/ja-JP.js +1 -1
  144. package/translations/pl-PL.js +1 -1
  145. package/translations/pt-BR.js +1 -1
  146. package/translations/ru-RU.js +1 -1
  147. package/translations/zh-CN.js +1 -1
  148. package/translations/zh-TW.js +1 -1
  149. package/typings/index.d.ts +65 -415
@@ -0,0 +1,425 @@
1
+ import * as chai from 'chai';
2
+ import chai_json_schema from 'chai-json-schema';
3
+ import chai_match_pattern from 'chai-match-pattern';
4
+ import chai_exclude from 'chai-exclude';
5
+ import chai_string from 'chai-string';
6
+ import * as output from '../output.js';
7
+
8
+ chai.use(chai_string);
9
+ // @ts-ignore
10
+ chai.use(chai_exclude);
11
+ chai.use(chai_match_pattern);
12
+ chai.use(chai_json_schema);
13
+
14
+ /**
15
+ * This helper allows performing assertions based on Chai.
16
+ *
17
+ * ### Examples
18
+ *
19
+ * Zero-configuration when paired with other helpers like REST, Playwright:
20
+ *
21
+ * ```js
22
+ * // inside codecept.conf.js
23
+ *{
24
+ * helpers: {
25
+ * Playwright: {...},
26
+ * Expect: {},
27
+ * }
28
+ *}
29
+ * ```
30
+ *
31
+ * ## Methods
32
+ */
33
+ class ExpectHelper {
34
+ /**
35
+ *
36
+ * @param {*} actualValue
37
+ * @param {*} expectedValue
38
+ * @param {*} [customErrorMsg]
39
+ */
40
+ expectEqual(actualValue, expectedValue, customErrorMsg = '') {
41
+ // @ts-ignore
42
+ output.output.step(`I expect "${JSON.stringify(actualValue)}" to equal "${JSON.stringify(expectedValue)}"`);
43
+ return chai.expect(actualValue, customErrorMsg).to.equal(expectedValue);
44
+ }
45
+
46
+ /**
47
+ *
48
+ * @param {*} actualValue
49
+ * @param {*} expectedValue
50
+ * @param {*} [customErrorMsg]
51
+ */
52
+ expectNotEqual(actualValue, expectedValue, customErrorMsg = '') {
53
+ // @ts-ignore
54
+ output.output.step(`I expect "${JSON.stringify(actualValue)}" to not equal "${JSON.stringify(expectedValue)}"`);
55
+ return chai.expect(actualValue, customErrorMsg).not.to.equal(expectedValue);
56
+ }
57
+
58
+ /**
59
+ *
60
+ * @param {*} actualValue
61
+ * @param {*} expectedValue
62
+ * @param {*} [customErrorMsg]
63
+
64
+ */
65
+ expectDeepEqual(actualValue, expectedValue, customErrorMsg = '') {
66
+ // @ts-ignore
67
+ output.output.step(`I expect "${JSON.stringify(actualValue)}" to deep equal "${JSON.stringify(expectedValue)}"`);
68
+ return chai.expect(actualValue, customErrorMsg).to.deep.equal(expectedValue);
69
+ }
70
+
71
+ /**
72
+ *
73
+ * @param {*} actualValue
74
+ * @param {*} expectedValue
75
+ * @param {*} [customErrorMsg]
76
+ */
77
+ expectNotDeepEqual(actualValue, expectedValue, customErrorMsg = '') {
78
+ // @ts-ignore
79
+ output.output.step(`I expect "${JSON.stringify(actualValue)}" to not deep equal "${JSON.stringify(expectedValue)}"`);
80
+ return chai.expect(actualValue, customErrorMsg).to.not.deep.equal(expectedValue);
81
+ }
82
+
83
+ /**
84
+ *
85
+ * @param {*} actualValue
86
+ * @param {*} expectedValueToContain
87
+ * @param {*} [customErrorMsg]
88
+ */
89
+ expectContain(actualValue, expectedValueToContain, customErrorMsg = '') {
90
+ // @ts-ignore
91
+ output.output.step(`I expect "${JSON.stringify(actualValue)}" to contain "${JSON.stringify(expectedValueToContain)}"`);
92
+ return chai.expect(actualValue, customErrorMsg).to.contain(
93
+ expectedValueToContain,
94
+ );
95
+ }
96
+
97
+ /**
98
+ *
99
+ * @param {*} actualValue
100
+ * @param {*} expectedValueToNotContain
101
+ * @param {*} [customErrorMsg]
102
+ */
103
+ expectNotContain(
104
+ actualValue,
105
+ expectedValueToNotContain,
106
+ customErrorMsg = '',
107
+ ) {
108
+ // @ts-ignore
109
+ output.output.step(`I expect "${JSON.stringify(actualValue)}" to not contain "${JSON.stringify(expectedValueToNotContain)}"`);
110
+ return chai.expect(actualValue, customErrorMsg).not.to.contain(
111
+ expectedValueToNotContain,
112
+ );
113
+ }
114
+
115
+ /**
116
+ *
117
+ * @param {*} actualValue
118
+ * @param {*} expectedValueToStartWith
119
+ * @param {*} [customErrorMsg]
120
+ */
121
+ expectStartsWith(actualValue, expectedValueToStartWith, customErrorMsg = '') {
122
+ // @ts-ignore
123
+ output.output.step(`I expect "${JSON.stringify(actualValue)}" to start with "${JSON.stringify(expectedValueToStartWith)}"`);
124
+ return chai.expect(actualValue, customErrorMsg).to.startsWith(
125
+ expectedValueToStartWith,
126
+ );
127
+ }
128
+
129
+ /**
130
+ *
131
+ * @param {*} actualValue
132
+ * @param {*} expectedValueToNotStartWith
133
+ * @param {*} [customErrorMsg]
134
+ */
135
+ expectNotStartsWith(
136
+ actualValue,
137
+ expectedValueToNotStartWith,
138
+ customErrorMsg = '',
139
+ ) {
140
+ // @ts-ignore
141
+ output.output.step(`I expect "${JSON.stringify(actualValue)}" to not start with "${JSON.stringify(expectedValueToNotStartWith)}"`);
142
+ return chai.expect(actualValue, customErrorMsg).not.to.startsWith(
143
+ expectedValueToNotStartWith,
144
+ );
145
+ }
146
+
147
+ /**
148
+ * @param {*} actualValue
149
+ * @param {*} expectedValueToEndWith
150
+ * @param {*} [customErrorMsg]
151
+ */
152
+ expectEndsWith(actualValue, expectedValueToEndWith, customErrorMsg = '') {
153
+ // @ts-ignore
154
+ output.output.step(`I expect "${JSON.stringify(actualValue)}" to end with "${JSON.stringify(expectedValueToEndWith)}"`);
155
+ return chai.expect(actualValue, customErrorMsg).to.endsWith(
156
+ expectedValueToEndWith,
157
+ );
158
+ }
159
+
160
+ /**
161
+ * @param {*} actualValue
162
+ * @param {*} expectedValueToNotEndWith
163
+ * @param {*} [customErrorMsg]
164
+ */
165
+ expectNotEndsWith(
166
+ actualValue,
167
+ expectedValueToNotEndWith,
168
+ customErrorMsg = '',
169
+ ) {
170
+ // @ts-ignore
171
+ output.output.step(`I expect "${JSON.stringify(actualValue)}" to not end with "${JSON.stringify(expectedValueToNotEndWith)}"`);
172
+ return chai.expect(actualValue, customErrorMsg).not.to.endsWith(
173
+ expectedValueToNotEndWith,
174
+ );
175
+ }
176
+
177
+ /**
178
+ * @param {*} targetData
179
+ * @param {*} jsonSchema
180
+ * @param {*} [customErrorMsg]
181
+ */
182
+ expectJsonSchema(targetData, jsonSchema, customErrorMsg = '') {
183
+ // @ts-ignore
184
+ output.output.step(`I expect "${JSON.stringify(targetData)}" to match this JSON schema "${JSON.stringify(jsonSchema)}"`);
185
+
186
+ return chai.expect(targetData, customErrorMsg).to.be.jsonSchema(jsonSchema);
187
+ }
188
+
189
+ /**
190
+ * @param {*} targetData
191
+ * @param {*} jsonSchema
192
+ * @param {*} [customErrorMsg]
193
+ * @param {*} [ajvOptions] Pass AJV options
194
+ */
195
+ expectJsonSchemaUsingAJV(
196
+ targetData,
197
+ jsonSchema,
198
+ customErrorMsg = '',
199
+ ajvOptions = { allErrors: true },
200
+ ) {
201
+ // @ts-ignore
202
+ output.output.step(`I expect "${JSON.stringify(targetData)}" to match this JSON schema using AJV "${JSON.stringify(jsonSchema)}"`);
203
+ chai.use(require('chai-json-schema-ajv').create(ajvOptions));
204
+ return chai.expect(targetData, customErrorMsg).to.be.jsonSchema(jsonSchema);
205
+ }
206
+
207
+ /**
208
+ * @param {*} targetData
209
+ * @param {*} propertyName
210
+ * @param {*} [customErrorMsg]
211
+ */
212
+ expectHasProperty(targetData, propertyName, customErrorMsg = '') {
213
+ // @ts-ignore
214
+ output.output.step(`I expect "${JSON.stringify(targetData)}" to have property: "${JSON.stringify(propertyName)}"`);
215
+ return chai.expect(targetData, customErrorMsg).to.have.property(propertyName);
216
+ }
217
+
218
+ /**
219
+ * @param {*} targetData
220
+ * @param {*} propertyName
221
+ * @param {*} [customErrorMsg]
222
+ */
223
+ expectHasAProperty(targetData, propertyName, customErrorMsg = '') {
224
+ // @ts-ignore
225
+ output.output.step(`I expect "${JSON.stringify(targetData)}" to have a property: "${JSON.stringify(propertyName)}"`);
226
+ return chai.expect(targetData, customErrorMsg).to.have.a.property(propertyName);
227
+ }
228
+
229
+ /**
230
+ * @param {*} targetData
231
+ * @param {*} type
232
+ * @param {*} [customErrorMsg]
233
+ */
234
+ expectToBeA(targetData, type, customErrorMsg = '') {
235
+ // @ts-ignore
236
+ output.output.step(`I expect "${JSON.stringify(targetData)}" to be a "${JSON.stringify(type)}"`);
237
+ return chai.expect(targetData, customErrorMsg).to.be.a(type);
238
+ }
239
+
240
+ /**
241
+ * @param {*} targetData
242
+ * @param {*} type
243
+ * @param {*} [customErrorMsg]
244
+ */
245
+ expectToBeAn(targetData, type, customErrorMsg = '') {
246
+ // @ts-ignore
247
+ output.output.step(`I expect "${JSON.stringify(targetData)}" to be an "${JSON.stringify(type)}"`);
248
+ return chai.expect(targetData, customErrorMsg).to.be.an(type);
249
+ }
250
+
251
+ /**
252
+ * @param {*} targetData
253
+ * @param {*} regex
254
+ * @param {*} [customErrorMsg]
255
+ */
256
+ expectMatchRegex(targetData, regex, customErrorMsg = '') {
257
+ // @ts-ignore
258
+ output.output.step(`I expect "${JSON.stringify(targetData)}" to match the regex "${JSON.stringify(regex)}"`);
259
+ return chai.expect(targetData, customErrorMsg).to.match(regex);
260
+ }
261
+
262
+ /**
263
+ * @param {*} targetData
264
+ * @param {*} length
265
+ * @param {*} [customErrorMsg]
266
+ */
267
+ expectLengthOf(targetData, length, customErrorMsg = '') {
268
+ // @ts-ignore
269
+ output.output.step(`I expect "${JSON.stringify(targetData)}" to have length of "${JSON.stringify(length)}"`);
270
+ return chai.expect(targetData, customErrorMsg).to.have.lengthOf(length);
271
+ }
272
+
273
+ /**
274
+ * @param {*} targetData
275
+ * @param {*} [customErrorMsg]
276
+ */
277
+ expectEmpty(targetData, customErrorMsg = '') {
278
+ // @ts-ignore
279
+ output.output.step(`I expect "${JSON.stringify(targetData)}" to be empty`);
280
+ return chai.expect(targetData, customErrorMsg).to.be.empty;
281
+ }
282
+
283
+ /**
284
+ * @param {*} targetData
285
+ * @param {*} [customErrorMsg]
286
+ */
287
+ expectTrue(targetData, customErrorMsg = '') {
288
+ // @ts-ignore
289
+ output.output.step(`I expect "${JSON.stringify(targetData)}" to be true`);
290
+ return chai.expect(targetData, customErrorMsg).to.be.true;
291
+ }
292
+
293
+ /**
294
+ * @param {*} targetData
295
+ * @param {*} [customErrorMsg]
296
+ */
297
+ expectFalse(targetData, customErrorMsg = '') {
298
+ // @ts-ignore
299
+ output.output.step(`I expect "${JSON.stringify(targetData)}" to be false`);
300
+ return chai.expect(targetData, customErrorMsg).to.be.false;
301
+ }
302
+
303
+ /**
304
+ * @param {*} targetData
305
+ * @param {*} aboveThan
306
+ * @param {*} [customErrorMsg]
307
+ */
308
+ expectAbove(targetData, aboveThan, customErrorMsg = '') {
309
+ // @ts-ignore
310
+ output.output.step(`I expect "${JSON.stringify(targetData)}" to be above ${JSON.stringify(aboveThan)}`);
311
+ return chai.expect(targetData, customErrorMsg).to.be.above(aboveThan);
312
+ }
313
+
314
+ /**
315
+ * @param {*} targetData
316
+ * @param {*} belowThan
317
+ * @param {*} [customErrorMsg]
318
+ */
319
+ expectBelow(targetData, belowThan, customErrorMsg = '') {
320
+ // @ts-ignore
321
+ output.output.step(`I expect "${JSON.stringify(targetData)}" to be below ${JSON.stringify(belowThan)}`);
322
+ return chai.expect(targetData, customErrorMsg).to.be.below(belowThan);
323
+ }
324
+
325
+ /**
326
+ * @param {*} targetData
327
+ * @param {*} lengthAboveThan
328
+ * @param {*} [customErrorMsg]
329
+ */
330
+ expectLengthAboveThan(targetData, lengthAboveThan, customErrorMsg = '') {
331
+ // @ts-ignore
332
+ output.output.step(`I expect "${JSON.stringify(targetData)}" to have length of above ${JSON.stringify(lengthAboveThan)}`);
333
+ return chai.expect(targetData, customErrorMsg).to.have.lengthOf.above(
334
+ lengthAboveThan,
335
+ );
336
+ }
337
+
338
+ /**
339
+ * @param {*} targetData
340
+ * @param {*} lengthBelowThan
341
+ * @param {*} [customErrorMsg]
342
+ */
343
+ expectLengthBelowThan(targetData, lengthBelowThan, customErrorMsg = '') {
344
+ // @ts-ignore
345
+ output.output.step(`I expect "${JSON.stringify(targetData)}" to have length of below ${JSON.stringify(lengthBelowThan)}`);
346
+ return chai.expect(targetData, customErrorMsg).to.have.lengthOf.below(
347
+ lengthBelowThan,
348
+ );
349
+ }
350
+
351
+ /**
352
+ * @param {*} actualValue
353
+ * @param {*} expectedValue
354
+ * @param {*} [customErrorMsg]
355
+ */
356
+ expectEqualIgnoreCase(actualValue, expectedValue, customErrorMsg = '') {
357
+ // @ts-ignore
358
+ output.output.step(`I expect and ingore case "${JSON.stringify(actualValue)}" to equal "${JSON.stringify(expectedValue)}"`);
359
+ return chai.expect(actualValue, customErrorMsg).to.equalIgnoreCase(
360
+ expectedValue,
361
+ );
362
+ }
363
+
364
+ /**
365
+ * expects members of two arrays are deeply equal
366
+ * @param {*} actualValue
367
+ * @param {*} expectedValue
368
+ * @param {*} [customErrorMsg]
369
+ */
370
+ expectDeepMembers(actualValue, expectedValue, customErrorMsg = '') {
371
+ // @ts-ignore
372
+ output.output.step(`I expect members of "${JSON.stringify(actualValue)}" and "${JSON.stringify(expectedValue)}" arrays are deeply equal`);
373
+ return chai.expect(actualValue, customErrorMsg).to.have.deep.members(
374
+ expectedValue,
375
+ );
376
+ }
377
+
378
+ /**
379
+ * expects an array to be a superset of another array
380
+ * @param {*} superset
381
+ * @param {*} set
382
+ * @param {*} [customErrorMsg]
383
+ */
384
+ expectDeepIncludeMembers(superset, set, customErrorMsg = '') {
385
+ // @ts-ignore
386
+ output.output.step(`I expect "${JSON.stringify(superset)}" array to be a superset of "${JSON.stringify(set)}" array`);
387
+ return chai.expect(superset, customErrorMsg).to.deep.include.members(
388
+ set,
389
+ );
390
+ }
391
+
392
+ /**
393
+ * expects members of two JSON objects are deeply equal excluding some properties
394
+ * @param {*} actualValue
395
+ * @param {*} expectedValue
396
+ * @param {*} fieldsToExclude
397
+ * @param {*} [customErrorMsg]
398
+ */
399
+ expectDeepEqualExcluding(
400
+ actualValue,
401
+ expectedValue,
402
+ fieldsToExclude,
403
+ customErrorMsg = '',
404
+ ) {
405
+ // @ts-ignore
406
+ output.output.step(`I expect members of "${JSON.stringify(actualValue)}" and "${JSON.stringify(expectedValue)}" JSON objects are deeply equal excluding properties: ${JSON.stringify(fieldsToExclude)}`);
407
+ return chai.expect(actualValue, customErrorMsg)
408
+ .excludingEvery(fieldsToExclude)
409
+ .to.deep.equal(expectedValue);
410
+ }
411
+
412
+ /**
413
+ * expects a JSON object matches a provided pattern
414
+ * @param {*} actualValue
415
+ * @param {*} expectedPattern
416
+ * @param {*} [customErrorMsg]
417
+ */
418
+ expectMatchesPattern(actualValue, expectedPattern, customErrorMsg = '') {
419
+ // @ts-ignore
420
+ output.output.step(`I expect "${JSON.stringify(actualValue)}" to match the ${JSON.stringify(expectedPattern)} pattern`);
421
+ return chai.expect(actualValue, customErrorMsg).to.matchPattern(expectedPattern);
422
+ }
423
+ }
424
+
425
+ export default ExpectHelper;