artes 1.7.4 → 1.7.6

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 (48) hide show
  1. package/README.md +781 -779
  2. package/assets/styles.css +4 -4
  3. package/cucumber.config.js +253 -253
  4. package/docs/ciExecutors.md +198 -198
  5. package/docs/emulationDevicesList.md +152 -152
  6. package/docs/functionDefinitions.md +2401 -2401
  7. package/docs/stepDefinitions.md +435 -433
  8. package/executer.js +266 -264
  9. package/index.js +50 -50
  10. package/package.json +56 -56
  11. package/src/helper/contextManager/browserManager.js +74 -74
  12. package/src/helper/contextManager/requestManager.js +23 -23
  13. package/src/helper/controller/elementController.js +210 -210
  14. package/src/helper/controller/findDuplicateTestNames.js +69 -69
  15. package/src/helper/controller/getEnvInfo.js +94 -94
  16. package/src/helper/controller/getExecutor.js +109 -109
  17. package/src/helper/controller/pomCollector.js +83 -83
  18. package/src/helper/controller/reportCustomizer.js +485 -485
  19. package/src/helper/controller/screenComparer.js +97 -108
  20. package/src/helper/controller/status-formatter.js +137 -137
  21. package/src/helper/controller/testCoverageCalculator.js +111 -111
  22. package/src/helper/executers/cleaner.js +23 -23
  23. package/src/helper/executers/exporter.js +19 -19
  24. package/src/helper/executers/helper.js +193 -191
  25. package/src/helper/executers/projectCreator.js +226 -222
  26. package/src/helper/executers/reportGenerator.js +91 -91
  27. package/src/helper/executers/testRunner.js +28 -28
  28. package/src/helper/executers/versionChecker.js +31 -31
  29. package/src/helper/imports/commons.js +65 -65
  30. package/src/helper/stepFunctions/APIActions.js +495 -495
  31. package/src/helper/stepFunctions/assertions.js +986 -986
  32. package/src/helper/stepFunctions/browserActions.js +87 -87
  33. package/src/helper/stepFunctions/elementInteractions.js +60 -60
  34. package/src/helper/stepFunctions/exporter.js +19 -19
  35. package/src/helper/stepFunctions/frameActions.js +72 -72
  36. package/src/helper/stepFunctions/keyboardActions.js +66 -66
  37. package/src/helper/stepFunctions/mouseActions.js +84 -84
  38. package/src/helper/stepFunctions/pageActions.js +43 -43
  39. package/src/hooks/context.js +15 -15
  40. package/src/hooks/hooks.js +287 -279
  41. package/src/stepDefinitions/API.steps.js +310 -310
  42. package/src/stepDefinitions/assertions.steps.js +1303 -1280
  43. package/src/stepDefinitions/browser.steps.js +74 -74
  44. package/src/stepDefinitions/frameActions.steps.js +76 -76
  45. package/src/stepDefinitions/keyboardActions.steps.js +264 -264
  46. package/src/stepDefinitions/mouseActions.steps.js +378 -378
  47. package/src/stepDefinitions/page.steps.js +71 -71
  48. package/src/stepDefinitions/random.steps.js +191 -191
@@ -1,1280 +1,1303 @@
1
- const {
2
- Then,
3
- selector,
4
- expect,
5
- element,
6
- extractVarsFromResponse,
7
- context,
8
- resolveVariable,
9
- } = require("../helper/imports/commons");
10
- const {
11
- screenComparer,
12
- } = require("artes/src/helper/controller/screenComparer");
13
- const { assert, frame } = require("../helper/stepFunctions/exporter");
14
- const Ajv = require("ajv");
15
-
16
- // Check if a selector should be attached
17
- Then("User expects {string} should be attached", async function (selector) {
18
- await assert.shouldBeAttached(selector);
19
- });
20
-
21
- Then(
22
- "User expects {int} th of {string} should be attached",
23
- async function (order, elements) {
24
- const nthElement = await frame.nth(elements, order);
25
- await assert.shouldBeAttached(nthElement);
26
- },
27
- );
28
-
29
- // Check if a selector should be checked
30
- Then("User expects {string} should be checked", async function (selector) {
31
- await assert.shouldBeChecked(selector);
32
- });
33
-
34
- Then(
35
- "User expects {int} th of {string} should be checked",
36
- async function (order, elements) {
37
- const nthElement = await frame.nth(elements, order);
38
- await assert.shouldBeChecked(nthElement);
39
- },
40
- );
41
-
42
- // Check if a selector should be disabled
43
- Then("User expects {string} should be disabled", async function (selector) {
44
- await assert.shouldBeDisabled(selector);
45
- });
46
-
47
- Then(
48
- "User expects {int} th of {string} should be disabled",
49
- async function (order, elements) {
50
- const nthElement = await frame.nth(elements, order);
51
- await assert.shouldBeDisabled(nthElement);
52
- },
53
- );
54
-
55
- // Check if a selector should be editable
56
- Then("User expects {string} should be editable", async function (selector) {
57
- await assert.shouldBeEditable(selector);
58
- });
59
-
60
- Then(
61
- "User expects {int} th of {string} should be editable",
62
- async function (order, elements) {
63
- const nthElement = await frame.nth(elements, order);
64
- await assert.shouldBeEditable(nthElement);
65
- },
66
- );
67
-
68
- // Check if a selector should be empty
69
- Then("User expects {string} should be empty", async function (selector) {
70
- await assert.shouldBeEmpty(selector);
71
- });
72
-
73
- Then(
74
- "User expects {int} th of {string} should be empty",
75
- async function (order, elements) {
76
- const nthElement = await frame.nth(elements, order);
77
- await assert.shouldBeEmpty(nthElement);
78
- },
79
- );
80
-
81
- // Check if a selector should be enabled
82
- Then("User expects {string} should be enabled", async function (selector) {
83
- await assert.shouldBeEnabled(selector);
84
- });
85
-
86
- Then(
87
- "User expects {int} th of {string} should be enabled",
88
- async function (order, elements) {
89
- const nthElement = await frame.nth(elements, order);
90
- await assert.shouldBeEnabled(nthElement);
91
- },
92
- );
93
-
94
- // Check if a selector should be focused
95
- Then("User expects {string} should be focused", async function (selector) {
96
- await assert.shouldBeFocused(selector);
97
- });
98
-
99
- Then(
100
- "User expects {int} th of {string} should be focused",
101
- async function (order, elements) {
102
- const nthElement = await frame.nth(elements, order);
103
- await assert.shouldBeFocused(nthElement);
104
- },
105
- );
106
-
107
- // Check if a selector should be hidden
108
- Then("User expects {string} should be hidden", async function (selector) {
109
- await assert.shouldBeHidden(selector);
110
- });
111
-
112
- Then(
113
- "User expects {int} th of {string} should be hidden",
114
- async function (order, elements) {
115
- const nthElement = await frame.nth(elements, order);
116
- await assert.shouldBeHidden(nthElement);
117
- },
118
- );
119
-
120
- // Check if a selector should be in the viewport
121
- Then(
122
- "User expects {string} should be on the screen",
123
- async function (selector) {
124
- await assert.shouldBeInViewport(selector);
125
- },
126
- );
127
-
128
- Then(
129
- "User expects {int} th of {string} should be on the screen",
130
- async function (order, elements) {
131
- const nthElement = await frame.nth(elements, order);
132
- await assert.shouldBeInViewport(nthElement);
133
- },
134
- );
135
-
136
- Then(
137
- "User expects {int} th of {string} should be screen",
138
- async function (order, elements) {
139
- const nthElement = await frame.nth(elements, order);
140
- await assert.shouldBeInViewport(nthElement);
141
- },
142
- );
143
-
144
- // Check if a selector should be visible
145
- Then("User expects {string} should be visible", async function (selector) {
146
- await assert.shouldBeVisible(selector);
147
- });
148
-
149
- Then(
150
- "User expects {int} th of {string} should be visible",
151
- async function (order, elements) {
152
- const nthElement = await frame.nth(elements, order);
153
- await assert.shouldBeVisible(nthElement);
154
- },
155
- );
156
-
157
- // Check if a selector should contain specific text
158
- Then(
159
- "User expects {string} should have {string} text",
160
- async function (selector, text) {
161
- await assert.shouldContainText(selector, text);
162
- },
163
- );
164
-
165
- Then(
166
- "User expects {int} th of {string} should have {string} text",
167
- async function (order, elements, text) {
168
- const nthElement = await frame.nth(elements, order);
169
- await assert.shouldContainText(nthElement, text);
170
- },
171
- );
172
-
173
- Then(
174
- "User expects default value of {string} should have {string} text",
175
- async (selector, text) => {
176
- const defaultValue = await element(selector).inputValue();
177
- await expect(defaultValue).toContain(text);
178
- },
179
- );
180
-
181
- Then(
182
- "User expects default value of {int} th of {string} should have {string} text",
183
- async function (order, elements, text) {
184
- const nthElement = await frame.nth(elements, order);
185
- await assert.toContain(nthElement, text);
186
- },
187
- );
188
-
189
- Then(
190
- "User expects multiple {string} should have {string} text",
191
- async (elements, expectedText) => {
192
- await assert.multipleElementsShouldContainText(elements, expectedText);
193
- },
194
- );
195
-
196
- // Check if a selector should have an accessible description
197
- Then(
198
- "User expects {string} should have {string} description",
199
- async function (selector, description) {
200
- await assert.shouldHaveAccessibleDescription(selector, description);
201
- },
202
- );
203
-
204
- Then(
205
- "User expects {int} th of {string} should have {string} description",
206
- async function (order, elements, text) {
207
- const nthElement = await frame.nth(elements, order);
208
- await assert.shouldHaveAccessibleDescription(nthElement, text);
209
- },
210
- );
211
-
212
- // Check if a selector should have an accessible name
213
- Then(
214
- "User expects {string} should have {string} name",
215
- async function (selector, name) {
216
- await assert.shouldHaveAccessibleName(selector, name);
217
- },
218
- );
219
-
220
- Then(
221
- "User expects {int} th of {string} should have {string} name",
222
- async function (order, elements, text) {
223
- const nthElement = await frame.nth(elements, order);
224
- await assert.shouldHaveAccessibleName(nthElement, text);
225
- },
226
- );
227
-
228
- // Check if a selector should have a specific attribute with a given value
229
- Then(
230
- "User expects {string} should have {string} attribute with {string} value",
231
- async function (selector, attribute, value) {
232
- await assert.shouldHaveAttribute(selector, attribute, value);
233
- },
234
- );
235
-
236
- Then(
237
- "User expects {int} th of {string} should have {string} attribute with {string} value",
238
- async function (order, elements, attribute, value) {
239
- const nthElement = await frame.nth(elements, order);
240
- await assert.shouldHaveAttribute(nthElement, attribute, value);
241
- },
242
- );
243
-
244
- // Check if a selector should have a specific class
245
- Then(
246
- "User expects {string} should have {string} class",
247
- async function (selector, className) {
248
- await assert.shouldHaveClass(selector, className);
249
- },
250
- );
251
-
252
- Then(
253
- "User expects {int} th of {string} should have {string} class",
254
- async function (order, elements, className) {
255
- const nthElement = await frame.nth(elements, order);
256
- await assert.shouldHaveClass(nthElement, className);
257
- },
258
- );
259
-
260
- // Check if a selector should have a specific count
261
- Then(
262
- "User expects count of {string} should be {int}",
263
- async function (selector, count) {
264
- await assert.shouldHaveCount(selector, count);
265
- },
266
- );
267
-
268
- // Check if a selector should have a specific CSS property with a given value
269
- Then(
270
- "User expects {string} should have {string} CSS property with {string} value",
271
- async function (selector, property, value) {
272
- await assert.shouldHaveCSS(selector, property, value);
273
- },
274
- );
275
-
276
- Then(
277
- "User expects {int} th of {string} should have {string} CSS property with {string} value",
278
- async function (order, elements, property, value) {
279
- const nthElement = await frame.nth(elements, order);
280
- await assert.shouldHaveCSS(nthElement, property, value);
281
- },
282
- );
283
-
284
- // Check if a selector should have a specific id
285
- Then(
286
- "User expects {string} should have {string} id",
287
- async function (selector, id) {
288
- await assert.shouldHaveId(selector, id);
289
- },
290
- );
291
-
292
- Then(
293
- "User expects {int} th of {string} should have {string} id",
294
- async function (order, elements, id) {
295
- const nthElement = await frame.nth(elements, order);
296
- await assert.shouldHaveId(nthElement, id);
297
- },
298
- );
299
-
300
- // Check if a selector should have a specific JavaScript property with a given value
301
- Then(
302
- "User expects {string} should have {string} JavaScript property with {string} value",
303
- async function (selector, property, value) {
304
- await assert.shouldHaveJSProperty(selector, property, value);
305
- },
306
- );
307
-
308
- Then(
309
- "User expects {int} th of {string} should have {string} JavaScript property with {string} value",
310
- async function (order, elements, property, value) {
311
- const nthElement = await frame.nth(elements, order);
312
- await assert.shouldHaveJSProperty(nthElement, property, value);
313
- },
314
- );
315
-
316
- // Check if a selector should have a specific role
317
- Then(
318
- "User expects {string} should have {string} role",
319
- async function (selector, role) {
320
- await assert.shouldHaveRole(selector, role);
321
- },
322
- );
323
-
324
- Then(
325
- "User expects {int} th of {string} should have {string} role",
326
- async function (order, elements, role) {
327
- const nthElement = await frame.nth(elements, order);
328
- await assert.shouldHaveId(nthElement, role);
329
- },
330
- );
331
-
332
- Then(
333
- "User expects that full page match with {string} screenshot",
334
- async function (baselineFilename) {
335
- await screenComparer(
336
- baselineFilename,
337
- (actualPath) =>
338
- context.page.screenshot({ path: actualPath, fullPage: true }),
339
- { maxDiffPercent: 0.01 },
340
- );
341
- },
342
- );
343
-
344
- Then(
345
- "User expects that full page match with {string} screenshot with {float}% difference",
346
- async function (baselineFilename, maxDiff) {
347
- await screenComparer(
348
- baselineFilename,
349
- (actualPath) =>
350
- context.page.screenshot({ path: actualPath, fullPage: true }),
351
- { maxDiffPercent: maxDiff / 100 },
352
- );
353
- },
354
- );
355
-
356
- Then(
357
- "User expects that page match with {string} screenshot",
358
- async function (baselineFilename) {
359
- await screenComparer(
360
- baselineFilename,
361
- (actualPath) =>
362
- context.page.screenshot({ path: actualPath, fullPage: false }),
363
- { maxDiffPercent: 0.01 },
364
- );
365
- },
366
- );
367
-
368
- Then(
369
- "User expects that page match with {string} screenshot with {float}% difference",
370
- async function (baselineFilename, maxDiff) {
371
- await screenComparer(
372
- baselineFilename,
373
- (actualPath) =>
374
- context.page.screenshot({ path: actualPath, fullPage: false }),
375
- { maxDiffPercent: maxDiff / 100 },
376
- );
377
- },
378
- );
379
-
380
- Then(
381
- "User expects that {string} element match with {string} screenshot",
382
- async function (selector, baselineFilename) {
383
- await screenComparer(
384
- baselineFilename,
385
- (actualPath) => element(selector).screenshot({ path: actualPath }),
386
- { maxDiffPercent: 0.01 },
387
- );
388
- },
389
- );
390
-
391
- Then(
392
- "User expects that {string} element match with {string} screenshot with {float}% difference",
393
- async function (selector, baselineFilename, maxDiff) {
394
- await screenComparer(
395
- baselineFilename,
396
- (actualPath) => element(selector).screenshot({ path: actualPath }),
397
- { maxDiffPercent: maxDiff / 100 },
398
- );
399
- },
400
- );
401
-
402
- // Check if a selector should have specific text
403
- Then(
404
- "User expects {string} should match {string} text",
405
- async function (selector, text) {
406
- await assert.shouldHaveText(selector, text);
407
- },
408
- );
409
-
410
- Then(
411
- "User expects {int} th of {string} should match {string} text",
412
- async function (order, elements, text) {
413
- const nthElement = await frame.nth(elements, order);
414
- await assert.shouldHaveText(nthElement, text);
415
- },
416
- );
417
-
418
- // Check if a selector should have a specific value
419
- Then(
420
- "User expects {string} should have {string} value",
421
- async function (selector, value) {
422
- await assert.shouldHaveValue(selector, value);
423
- },
424
- );
425
-
426
- Then(
427
- "User expects {int} th of {string} should have {string} value",
428
- async function (order, elements, value) {
429
- const nthElement = await frame.nth(elements, order);
430
- await assert.shouldHaveValue(nthElement, value);
431
- },
432
- );
433
-
434
- // Check if a selector should have specific values
435
- Then(
436
- "User expects {string} should have {string} values",
437
- async function (selector, values) {
438
- await assert.shouldHaveValues(selector, values.split(","));
439
- },
440
- );
441
-
442
- // Check if the page should have a screenshot
443
- Then("User expects the page should have a screenshot", async function () {
444
- await assert.shouldPageHaveScreenshot();
445
- });
446
-
447
- // Check if the page should have a specific title
448
- Then(
449
- "User expects the page should have {string} title",
450
- async function (title) {
451
- await assert.shouldPageHaveTitle(title);
452
- },
453
- );
454
-
455
- // Check if the page should have a specific URL
456
- Then("User expects to be in {string} page", async function (url) {
457
- const URL = await selector(url);
458
- await assert.shouldPageHaveURL(URL);
459
- });
460
-
461
- // Check if a selector should not be attached
462
- Then("User expects {string} should not be attached", async function (selector) {
463
- await assert.shouldNotBeAttached(selector);
464
- });
465
-
466
- Then(
467
- "User expects {int} th of {string} should be not be attached",
468
- async function (order, elements) {
469
- const nthElement = await frame.nth(elements, order);
470
- await assert.shouldNotBeAttached(nthElement);
471
- },
472
- );
473
-
474
- // Check if a selector should not be checked
475
- Then("User expects {string} should not be checked", async function (selector) {
476
- await assert.shouldNotBeChecked(selector);
477
- });
478
-
479
- Then(
480
- "User expects {int} th of {string} should be not be checked",
481
- async function (order, elements) {
482
- const nthElement = await frame.nth(elements, order);
483
- await assert.shouldNotBeChecked(nthElement);
484
- },
485
- );
486
-
487
- // Check if a selector should not be disabled
488
- Then("User expects {string} should not be disabled", async function (selector) {
489
- await assert.shouldNotBeDisabled(selector);
490
- });
491
-
492
- Then(
493
- "User expects {int} th of {string} should be not be disabled",
494
- async function (order, elements) {
495
- const nthElement = await frame.nth(elements, order);
496
- await assert.shouldNotBeDisabled(nthElement);
497
- },
498
- );
499
-
500
- // Check if a selector should not be editable
501
- Then("User expects {string} should not be editable", async function (selector) {
502
- await assert.shouldNotBeEditable(selector);
503
- });
504
-
505
- Then(
506
- "User expects {int} th of {string} should be not be editable",
507
- async function (order, elements) {
508
- const nthElement = await frame.nth(elements, order);
509
- await assert.shouldNotBeEditable(nthElement);
510
- },
511
- );
512
-
513
- // Check if a selector should not be empty
514
- Then("User expects {string} should not be empty", async function (selector) {
515
- await assert.shouldNotBeEmpty(selector);
516
- });
517
-
518
- Then(
519
- "User expects {int} th of {string} should be not be empty",
520
- async function (order, elements) {
521
- const nthElement = await frame.nth(elements, order);
522
- await assert.shouldNotBeEmpty(nthElement);
523
- },
524
- );
525
-
526
- // Check if a selector should not be enabled
527
- Then("User expects {string} should not be enabled", async function (selector) {
528
- await assert.shouldNotBeEnabled(selector);
529
- });
530
-
531
- Then(
532
- "User expects {int} th of {string} should be not be enabled",
533
- async function (order, elements) {
534
- const nthElement = await frame.nth(elements, order);
535
- await assert.shouldNotBeEnabled(nthElement);
536
- },
537
- );
538
-
539
- // Check if a selector should not be focused
540
- Then("User expects {string} should not be focused", async function (selector) {
541
- await assert.shouldNotBeFocused(selector);
542
- });
543
-
544
- Then(
545
- "User expects {int} th of {string} should be not be focused",
546
- async function (order, elements) {
547
- const nthElement = await frame.nth(elements, order);
548
- await assert.shouldNotBeFocused(nthElement);
549
- },
550
- );
551
-
552
- // Check if a selector should not be hidden
553
- Then("User expects {string} should not be hidden", async function (selector) {
554
- await assert.shouldNotBeHidden(selector);
555
- });
556
-
557
- Then(
558
- "User expects {int} th of {string} should be not be hidden",
559
- async function (order, elements) {
560
- const nthElement = await frame.nth(elements, order);
561
- await assert.shouldNotBeHidden(nthElement);
562
- },
563
- );
564
-
565
- // Check if a selector should not be in the viewport
566
- Then(
567
- "User expects {string} should not be on the screen",
568
- async function (selector) {
569
- await assert.shouldNotBeInViewport(selector);
570
- },
571
- );
572
-
573
- Then(
574
- "User expects {int} th of {string} should not be on the screen",
575
- async function (order, elements) {
576
- const nthElement = await frame.nth(elements, order);
577
- await assert.shouldNotBeInViewport(nthElement);
578
- },
579
- );
580
-
581
- // Check if a selector should not be visible
582
- Then("User expects {string} should not be visible", async function (selector) {
583
- await assert.shouldNotBeVisible(selector);
584
- });
585
-
586
- Then(
587
- "User expects {int} th of {string} should not be visible",
588
- async function (order, elements) {
589
- const nthElement = await frame.nth(elements, order);
590
- await assert.shouldNotBeVisible(nthElement);
591
- },
592
- );
593
-
594
- // Check if a selector should not contain specific text
595
- Then(
596
- "User expects {string} should not have {string} text",
597
- async function (selector, text) {
598
- await assert.shouldNotContainText(selector, text);
599
- },
600
- );
601
-
602
- Then(
603
- "User expects {int} th of {string} should not have {string} text",
604
- async function (order, elements, text) {
605
- const nthElement = await frame.nth(elements, order);
606
- await assert.shouldNotContainText(nthElement, text);
607
- },
608
- );
609
-
610
- // Check if a selector should not have an accessible description
611
- Then(
612
- "User expects {string} should not have {string} description",
613
- async function (selector, description) {
614
- await assert.shouldNotHaveAccessibleDescription(selector, description);
615
- },
616
- );
617
-
618
- Then(
619
- "User expects {int} th of {string} should not have {string} description",
620
- async function (order, elements, text) {
621
- const nthElement = await frame.nth(elements, order);
622
- await assert.shouldNotHaveAccessibleDescription(nthElement, text);
623
- },
624
- );
625
-
626
- // Check if a selector should not have an accessible name
627
- Then(
628
- "User expects {string} should not have {string} name",
629
- async function (selector, name) {
630
- await assert.shouldNotHaveAccessibleName(selector, name);
631
- },
632
- );
633
-
634
- Then(
635
- "User expects {int} th of {string} should not have {string} name",
636
- async function (order, elements, text) {
637
- const nthElement = await frame.nth(elements, order);
638
- await assert.shouldNotHaveAccessibleName(nthElement, text);
639
- },
640
- );
641
-
642
- // Check if a selector should not have a specific attribute with a given value
643
- Then(
644
- "User expects {string} should not have {string} attribute with {string} value",
645
- async function (selector, attribute, value) {
646
- await assert.shouldNotHaveAttribute(selector, attribute, value);
647
- },
648
- );
649
-
650
- Then(
651
- "User expects {int} th of {string} should have {string} attribute with {string} value",
652
- async function (order, elements, attribute, value) {
653
- const nthElement = await frame.nth(elements, order);
654
- await assert.shouldNotHaveAttribute(nthElement, attribute, value);
655
- },
656
- );
657
-
658
- // Check if a selector should not have a specific class
659
- Then(
660
- "User expects {string} should not have {string} class",
661
- async function (selector, className) {
662
- await assert.shouldNotHaveClass(selector, className);
663
- },
664
- );
665
-
666
- Then(
667
- "User expects {int} th of {string} should not have {string} class",
668
- async function (order, elements, text) {
669
- const nthElement = await frame.nth(elements, order);
670
- await assert.shouldNotHaveClass(nthElement, text);
671
- },
672
- );
673
-
674
- // Check if a selector should not have a specific count
675
- Then(
676
- "User expects count of {string} should not be {int}",
677
- async function (selector, count) {
678
- await assert.shouldNotHaveCount(selector, count);
679
- },
680
- );
681
-
682
- // Check if a selector should not have a specific CSS property with a given value
683
- Then(
684
- "User expects {string} should not have {string} CSS property with {string} value",
685
- async function (selector, property, value) {
686
- await assert.shouldNotHaveCSS(selector, property, value);
687
- },
688
- );
689
-
690
- Then(
691
- "User expects {int} th of {string} should not have {string} CSS property with {string} value",
692
- async function (order, elements, property, value) {
693
- const nthElement = await frame.nth(elements, order);
694
- await assert.shouldNotHaveCSS(nthElement, property, value);
695
- },
696
- );
697
-
698
- // Check if a selector should not have a specific ID
699
- Then(
700
- "User expects {string} should not have {string} id",
701
- async function (selector, id) {
702
- await assert.shouldNotHaveId(selector, id);
703
- },
704
- );
705
-
706
- Then(
707
- "User expects {int} th of {string} should not have {string} id",
708
- async function (order, elements, text) {
709
- const nthElement = await frame.nth(elements, order);
710
- await assert.shouldNotHaveId(nthElement, text);
711
- },
712
- );
713
-
714
- // Check if a selector should not have a specific JavaScript property with a given value
715
- Then(
716
- "User expects {string} should not have {string} JavaScript property with {string} value",
717
- async function (selector, property, value) {
718
- await assert.shouldNotHaveJSProperty(selector, property, value);
719
- },
720
- );
721
-
722
- Then(
723
- "User expects {int} th of {string} should not have {string} JavaScript property with {string} value",
724
- async function (order, elements, property, value) {
725
- const nthElement = await frame.nth(elements, order);
726
- await assert.shouldNotHaveJSProperty(nthElement, property, value);
727
- },
728
- );
729
-
730
- // Check if a selector should not have a specific role
731
- Then(
732
- "User expects {string} should not have {string} role",
733
- async function (selector, role) {
734
- await assert.shouldNotHaveRole(selector, role);
735
- },
736
- );
737
-
738
- Then(
739
- "User expects {int} th of {string} should not have {string} role",
740
- async function (order, elements, text) {
741
- const nthElement = await frame.nth(elements, order);
742
- await assert.shouldNotHaveRole(nthElement, text);
743
- },
744
- );
745
-
746
- // Check if a selector should not have specific text
747
- Then(
748
- "User expects {string} should not match {string} text",
749
- async function (selector, text) {
750
- await assert.shouldNotHaveText(selector, text);
751
- },
752
- );
753
-
754
- Then(
755
- "User expects {int} th of {string} should not have {string} text",
756
- async function (order, elements, text) {
757
- const nthElement = await frame.nth(elements, order);
758
- await assert.shouldNotHaveText(nthElement, text);
759
- },
760
- );
761
-
762
- // Check if a selector should not have a specific value
763
- Then(
764
- "User expects {string} should not have {string} value",
765
- async function (selector, value) {
766
- await assert.shouldNotHaveValue(selector, value);
767
- },
768
- );
769
-
770
- Then(
771
- "User expects {int} th of {string} should not have {string} value",
772
- async function (order, elements, text) {
773
- const nthElement = await frame.nth(elements, order);
774
- await assert.shouldNotHaveValue(nthElement, text);
775
- },
776
- );
777
-
778
- // Check if a selector should not have specific values
779
- Then(
780
- "User expects {string} should not have {string} values",
781
- async function (selector, values) {
782
- await assert.shouldNotHaveValues(selector, values.split(","));
783
- },
784
- );
785
-
786
- // Check if the page should not have a screenshot
787
- Then("User expects the page should not have a screenshot", async function () {
788
- await assert.shouldNotPageHaveScreenshot();
789
- });
790
-
791
- // Check if the page should not have a specific title
792
- Then(
793
- "User expects the page should not have {string} title",
794
- async function (title) {
795
- await assert.shouldNotPageHaveTitle(title);
796
- },
797
- );
798
-
799
- // Check if the page should not have a specific URL
800
- Then("User expects the page url should not be {string}", async function (url) {
801
- await assert.shouldNotPageHaveURL(url);
802
- });
803
-
804
- Then("User is not on {string} page", async function (url) {
805
- await assert.shouldNotPageHaveURL(url);
806
- });
807
-
808
- // Check if a response should not be OK
809
- Then("The response should not be OK", async function (response) {
810
- await assert.shouldNotResponseBeOK(response);
811
- });
812
-
813
- // Check if a selector's value should be equal to the expected value
814
- Then(
815
- "User expects {string} should be {string} text",
816
- async function (selector, expected) {
817
- await assert.shouldBe(selector, expected);
818
- },
819
- );
820
-
821
- // Check if a selector's value should be close to the expected value within a precision
822
- Then(
823
- "User expects {string} should be close to {float} with precision {int}",
824
- async function (selector, expected, precision) {
825
- await assert.shouldBeCloseTo(selector, expected, precision);
826
- },
827
- );
828
-
829
- // Check if a selector's value should be defined
830
- Then("User expects {string} should be defined", async function (selector) {
831
- await assert.shouldBeDefined(selector);
832
- });
833
-
834
- // Check if a selector's text content should be falsy
835
- Then("User expects {string} should be falsy", async function (selector) {
836
- await assert.shouldBeFalsy(selector);
837
- });
838
-
839
- // Check if a selector's value should be greater than the expected value
840
- Then(
841
- "User expects {string} should be greater than {float}",
842
- async function (selector, expected) {
843
- await assert.shouldBeGreaterThan(selector, expected);
844
- },
845
- );
846
-
847
- // Check if a selector's value should be greater than or equal to the expected value
848
- Then(
849
- "User expects {string} should be greater than or equal to {float}",
850
- async function (selector, expected) {
851
- await assert.shouldBeGreaterThanOrEqual(selector, expected);
852
- },
853
- );
854
-
855
- // Check if a selector's value should be an instance of a specific constructor
856
- Then(
857
- "User expects {string} should be an instance of {string}",
858
- async function (selector, constructor) {
859
- await assert.shouldBeInstanceOf(selector, constructor);
860
- },
861
- );
862
-
863
- // Check if a selector's value should be less than the expected value
864
- Then(
865
- "User expects {string} should be less than {float}",
866
- async function (selector, expected) {
867
- await assert.shouldBeLessThan(selector, expected);
868
- },
869
- );
870
-
871
- // Check if a selector's value should be less than or equal to the expected value
872
- Then(
873
- "User expects {string} should be less than or equal to {float}",
874
- async function (selector, expected) {
875
- await assert.shouldBeLessThanOrEqual(selector, expected);
876
- },
877
- );
878
-
879
- // Check if a selector's value should be NaN
880
- Then("User expects {string} should be NaN", async function (selector) {
881
- await assert.shouldBeNaN(selector);
882
- });
883
-
884
- // Check if a selector's value should be null
885
- Then("User expects {string} should be null", async function (selector) {
886
- await assert.shouldBeNull(selector);
887
- });
888
-
889
- // Check if a selector's value should be truthy
890
- Then("User expects {string} should be truthy", async function (selector) {
891
- await assert.shouldBeTruthy(selector);
892
- });
893
-
894
- // Check if a selector's value should be undefined
895
- Then("User expects {string} should be undefined", async function (selector) {
896
- await assert.shouldBeUndefined(selector);
897
- });
898
-
899
- // Check if a selector's value should contain a specific substring
900
- Then(
901
- "User expects {string} should have {string} substring",
902
- async function (selector, substring) {
903
- await assert.shouldContain(selector, substring);
904
- },
905
- );
906
-
907
- // Check if a selector's value should contain an equal value
908
- Then(
909
- "User expects {string} should contain equal {string}",
910
- async function (selector, expected) {
911
- await assert.shouldContainEqual(selector, expected);
912
- },
913
- );
914
-
915
- // Check if a selector's value should equal the expected value
916
- Then(
917
- "User expects {string} should equal {int}",
918
- async function (selector, expected) {
919
- await assert.shouldEqual(selector, expected);
920
- },
921
- );
922
-
923
- // Check if a selector's text content should have a specific length
924
- Then(
925
- "User expects length of {string} should be {int}",
926
- async function (selector, length) {
927
- await assert.shouldHaveLength(selector, length);
928
- },
929
- );
930
-
931
- // Check if a selector's text content should have a specific property
932
- Then(
933
- "User expects {string} should have {string} property",
934
- async function (selector, property) {
935
- await assert.shouldHaveProperty(selector, property);
936
- },
937
- );
938
-
939
- // Check if a selector's text content should match a specific regex
940
- Then(
941
- "User expects {string} should match {string} regex",
942
- async function (selector, regex) {
943
- await assert.shouldMatch(selector, new RegExp(regex));
944
- },
945
- );
946
-
947
- // Check if a selector's text content should match a specific object
948
- Then(
949
- "User expects {string} should match {string} object",
950
- async function (selector, object) {
951
- await assert.shouldMatchObject(selector, JSON.parse(object));
952
- },
953
- );
954
-
955
- // Check if a selector's text content should strictly equal the expected value
956
- Then(
957
- "User expects {string} should strictly equal {string}",
958
- async function (selector, expected) {
959
- await assert.shouldStrictEqual(selector, expected);
960
- },
961
- );
962
-
963
- // Check if a async function should throw an error
964
- Then("The async function should throw", async function (fn) {
965
- await assert.shouldThrow(fn);
966
- });
967
-
968
- // Check if the text content of a selector should be an instance of a specific constructor
969
- Then(
970
- "User expects {string} should be any instance of {string}",
971
- async function (selector, constructor) {
972
- await assert.shouldAny(selector, constructor);
973
- },
974
- );
975
-
976
- // Check if the text content of a selector may be anything (truthy)
977
- Then("User expects {string} may be anything", async function (selector) {
978
- await assert.shouldAnything(selector);
979
- });
980
-
981
- // Check if the text content of a selector should contain any of the specified elements in an array
982
- Then(
983
- "User expects {string} should contain {string} array elements",
984
- async function (selector, elements) {
985
- const parsedElements = elements.split(",");
986
- await assert.shouldArrayContaining(selector, parsedElements);
987
- },
988
- );
989
-
990
- // Check if the text content of a selector should be close to the expected value within a precision
991
- Then(
992
- "User expects {string} should be close to {float} with precision {int}",
993
- async function (selector, expected, precision) {
994
- await assert.shouldCloseTo(selector, expected, precision);
995
- },
996
- );
997
-
998
- // Check if the text content of a selector should contain the specified properties in an object
999
- Then(
1000
- "User expects {string} should contain {string} object properties",
1001
- async function (selector, properties) {
1002
- const parsedProperties = properties.split(",");
1003
- await assert.shouldObjectContaining(selector, parsedProperties);
1004
- },
1005
- );
1006
-
1007
- // Check if the text content of a selector should contain a specific substring
1008
- Then(
1009
- "User expects {string} should have {string} substring",
1010
- async function (selector, substring) {
1011
- await assert.shouldStringContaining(selector, substring);
1012
- },
1013
- );
1014
-
1015
- // Check if the text content of a selector should match a specific regex
1016
- Then(
1017
- "User expects {string} should match {string} regex",
1018
- async function (selector, regex) {
1019
- await assert.shouldStringMatching(selector, new RegExp(regex));
1020
- },
1021
- );
1022
-
1023
- // Check if a selector's text content should not be equal to the expected value
1024
- Then(
1025
- "User expects {string} should not be {string} text",
1026
- async function (selector, expected) {
1027
- await assert.shouldNotBe(selector, expected);
1028
- },
1029
- );
1030
-
1031
- // Check if a selector's text content should not be close to the expected value within a precision
1032
- Then(
1033
- "User expects {string} should not be close to {float} with precision {int}",
1034
- async function (selector, expected, precision) {
1035
- await assert.shouldNotBeCloseTo(selector, expected, precision);
1036
- },
1037
- );
1038
-
1039
- // Check if a selector's text content should not be defined
1040
- Then("User expects {string} should not be defined", async function (selector) {
1041
- await assert.shouldNotBeDefined(selector);
1042
- });
1043
-
1044
- // Check if a selector's text content should not be falsy
1045
- Then("User expects {string} should not be falsy", async function (selector) {
1046
- await assert.shouldNotBeFalsy(selector);
1047
- });
1048
-
1049
- // Check if a selector's text content should not be greater than the expected value
1050
- Then(
1051
- "User expects {string} should not be greater than {float}",
1052
- async function (selector, expected) {
1053
- await assert.shouldNotBeGreaterThan(selector, expected);
1054
- },
1055
- );
1056
-
1057
- // Check if a selector's text content should not be greater than or equal to the expected value
1058
- Then(
1059
- "User expects {string} should not be greater than or equal to {float}",
1060
- async function (selector, expected) {
1061
- await assert.shouldNotBeGreaterThanOrEqual(selector, expected);
1062
- },
1063
- );
1064
-
1065
- // Check if a selector's text content should not be an instance of a specific constructor
1066
- Then(
1067
- "User expects {string} should not be an instance of {string}",
1068
- async function (selector, constructor) {
1069
- await assert.shouldNotBeInstanceOf(selector, constructor);
1070
- },
1071
- );
1072
-
1073
- // Check if a selector's text content should not be less than the expected value
1074
- Then(
1075
- "User expects {string} should not be less than {float}",
1076
- async function (selector, expected) {
1077
- await assert.shouldNotBeLessThan(selector, expected);
1078
- },
1079
- );
1080
-
1081
- // Check if a selector's text content should not be less than or equal to the expected value
1082
- Then(
1083
- "User expects {string} should not be less than or equal to {float}",
1084
- async function (selector, expected) {
1085
- await assert.shouldNotBeLessThanOrEqual(selector, expected);
1086
- },
1087
- );
1088
-
1089
- // Check if a selector's text content should not be NaN
1090
- Then("User expects {string} should not be NaN", async function (selector) {
1091
- await assert.shouldNotBeNaN(selector);
1092
- });
1093
-
1094
- // Check if a selector's text content should not be null
1095
- Then("User expects {string} should not be null", async function (selector) {
1096
- await assert.shouldNotBeNull(selector);
1097
- });
1098
-
1099
- // Check if a selector's text content should not be truthy
1100
- Then("User expects {string} should not be truthy", async function (selector) {
1101
- await assert.shouldNotBeTruthy(selector);
1102
- });
1103
-
1104
- // Check if a selector's text content should not be undefined
1105
- Then(
1106
- "User expects {string} should not be undefined",
1107
- async function (selector) {
1108
- await assert.shouldNotBeUndefined(selector);
1109
- },
1110
- );
1111
-
1112
- // Check if a selector's text content should not contain a specific substring
1113
- Then(
1114
- "User expects {string} should not have {string} substring",
1115
- async function (selector, substring) {
1116
- await assert.shouldNotContain(selector, substring);
1117
- },
1118
- );
1119
-
1120
- // Check if a selector's text content should not contain an equal value
1121
- Then(
1122
- "User expects {string} should not contain equal {string}",
1123
- async function (selector, expected) {
1124
- await assert.shouldNotContainEqual(selector, expected);
1125
- },
1126
- );
1127
-
1128
- // Check if a selector's text content should not equal the expected value
1129
- Then(
1130
- "User expects {string} should not equal {string}",
1131
- async function (selector, expected) {
1132
- await assert.shouldNotEqual(selector, expected);
1133
- },
1134
- );
1135
-
1136
- // Check if a selector's text content should not have a specific length
1137
- Then(
1138
- "User expects length of {string} should not be {int} ",
1139
- async function (selector, length) {
1140
- await assert.shouldNotHaveLength(selector, length);
1141
- },
1142
- );
1143
-
1144
- // Check if a selector's text content should not have a specific property
1145
- Then(
1146
- "User expects {string} should not have {string} property",
1147
- async function (selector, property) {
1148
- await assert.shouldNotHaveProperty(selector, property);
1149
- },
1150
- );
1151
-
1152
- // Check if a selector's text content should not match a specific regex
1153
- Then(
1154
- "User expects {string} should not match {string} regex",
1155
- async function (selector, regex) {
1156
- await assert.shouldNotMatch(selector, new RegExp(regex));
1157
- },
1158
- );
1159
-
1160
- // Check if a selector's text content should not match a specific object
1161
- Then(
1162
- "User expects {string} should not match {string} object",
1163
- async function (selector, object) {
1164
- await assert.shouldNotMatchObject(selector, JSON.parse(object));
1165
- },
1166
- );
1167
-
1168
- // Check if a async function should not throw an error
1169
- Then("The async function should not throw", async function (fn) {
1170
- await assert.shouldNotThrow(fn);
1171
- });
1172
-
1173
- // Check if a selector's text content should not be any instance of a specific constructor
1174
- Then(
1175
- "User expects {string} should not be any instance of {string}",
1176
- async function (selector, constructor) {
1177
- await assert.shouldNotAny(selector, constructor);
1178
- },
1179
- );
1180
-
1181
- // Check if a selector's text content may not be anything (falsy)
1182
- Then("User expects {string} may not be anything", async function (selector) {
1183
- await assert.shouldNotAnything(selector);
1184
- });
1185
-
1186
- // Check if a selector's text content should not contain any of the specified elements in an array
1187
- Then(
1188
- "User expects {string} should not contain {string} array elements",
1189
- async function (selector, elements) {
1190
- const parsedElements = elements.split(",");
1191
- await assert.shouldNotArrayContaining(selector, parsedElements);
1192
- },
1193
- );
1194
-
1195
- // Check if a selector's text content should not be close to the expected value within a precision
1196
- Then(
1197
- "User expects {string} should not be close to {float} with precision {int}",
1198
- async function (selector, expected, precision) {
1199
- await assert.shouldNotCloseTo(selector, expected, precision);
1200
- },
1201
- );
1202
-
1203
- // Check if a selector's text content should not contain the specified properties in an object
1204
- Then(
1205
- "User expects {string} should not contain {string} object properties",
1206
- async function (selector, properties) {
1207
- const parsedProperties = JSON.parse(properties);
1208
- await assert.shouldNotObjectContaining(selector, parsedProperties);
1209
- },
1210
- );
1211
-
1212
- // Check if a selector's text content should not contain a specific substring
1213
- Then(
1214
- "User expects {string} should not contain {string} substring",
1215
- async function (selector, substring) {
1216
- await assert.shouldNotStringContaining(selector, substring);
1217
- },
1218
- );
1219
-
1220
- // Check if a selector's text content should not match a specific regex
1221
- Then(
1222
- "User expects {string} should not match {string} regex",
1223
- async function (selector, regex) {
1224
- await assert.shouldNotStringMatching(selector, new RegExp(regex));
1225
- },
1226
- );
1227
-
1228
- Then("User expects should have {int} {string}", async (count, elements) => {
1229
- const elementCount = await frame.count(elements);
1230
- expect(elementCount).toEqual(count);
1231
- });
1232
-
1233
- Then(
1234
- "User expects that response has {string} field with {string} value",
1235
- async (field, value) => {
1236
- extractVarsFromResponse(context.response["Response Body"], field);
1237
- const varToString = JSON.stringify(context.vars[field]);
1238
- expect(varToString).toBe(value);
1239
- },
1240
- );
1241
-
1242
- Then(
1243
- "User expects that {string} should match {string}",
1244
- async (value1, value2) => {
1245
- await expect(resolveVariable(value1)).toBe(value2);
1246
- },
1247
- );
1248
-
1249
- Then(
1250
- "User expects that response body should match {string} schema",
1251
- async function (expectedSchema) {
1252
- expectedSchema = await resolveVariable(expectedSchema);
1253
- if (expectedSchema != "") {
1254
- const schema = await selector(expectedSchema);
1255
- const ajv = await new Ajv();
1256
- const validate = await ajv.compile(schema);
1257
- const responseBody = await context.response["Response Body"];
1258
- const valid = await validate(responseBody);
1259
- await expect(valid).toBe(true);
1260
- }
1261
- },
1262
- );
1263
-
1264
- Then(
1265
- "User expects that request should have {int} status code",
1266
- async function (expectedStatusCode) {
1267
- expectedStatusCode = await resolveVariable(expectedStatusCode);
1268
- const actualStatusCode = await context.response.Response.status();
1269
- expect(actualStatusCode).toBe(expectedStatusCode);
1270
- },
1271
- );
1272
-
1273
- Then(
1274
- "User expects that response should have {int} status code",
1275
- async function (expectedStatusCode) {
1276
- expectedStatusCode = await resolveVariable(expectedStatusCode);
1277
- const actualStatusCode = await context.response.Response.status();
1278
- expect(actualStatusCode).toBe(expectedStatusCode);
1279
- },
1280
- );
1
+ const {
2
+ Then,
3
+ selector,
4
+ expect,
5
+ element,
6
+ extractVarsFromResponse,
7
+ context,
8
+ resolveVariable,
9
+ } = require("../helper/imports/commons");
10
+ const {
11
+ screenComparer,
12
+ } = require("../helper/controller/screenComparer");
13
+ const { assert, frame } = require("../helper/stepFunctions/exporter");
14
+ const Ajv = require("ajv");
15
+
16
+ // Check if a selector should be attached
17
+ Then("User expects {string} should be attached", async function (selector) {
18
+ await assert.shouldBeAttached(selector);
19
+ });
20
+
21
+ Then(
22
+ "User expects {int} th of {string} should be attached",
23
+ async function (order, elements) {
24
+ const nthElement = await frame.nth(elements, order);
25
+ await assert.shouldBeAttached(nthElement);
26
+ },
27
+ );
28
+
29
+ // Check if a selector should be checked
30
+ Then("User expects {string} should be checked", async function (selector) {
31
+ await assert.shouldBeChecked(selector);
32
+ });
33
+
34
+ Then(
35
+ "User expects {int} th of {string} should be checked",
36
+ async function (order, elements) {
37
+ const nthElement = await frame.nth(elements, order);
38
+ await assert.shouldBeChecked(nthElement);
39
+ },
40
+ );
41
+
42
+ // Check if a selector should be disabled
43
+ Then("User expects {string} should be disabled", async function (selector) {
44
+ await assert.shouldBeDisabled(selector);
45
+ });
46
+
47
+ Then(
48
+ "User expects {int} th of {string} should be disabled",
49
+ async function (order, elements) {
50
+ const nthElement = await frame.nth(elements, order);
51
+ await assert.shouldBeDisabled(nthElement);
52
+ },
53
+ );
54
+
55
+ // Check if a selector should be editable
56
+ Then("User expects {string} should be editable", async function (selector) {
57
+ await assert.shouldBeEditable(selector);
58
+ });
59
+
60
+ Then(
61
+ "User expects {int} th of {string} should be editable",
62
+ async function (order, elements) {
63
+ const nthElement = await frame.nth(elements, order);
64
+ await assert.shouldBeEditable(nthElement);
65
+ },
66
+ );
67
+
68
+ // Check if a selector should be empty
69
+ Then("User expects {string} should be empty", async function (selector) {
70
+ await assert.shouldBeEmpty(selector);
71
+ });
72
+
73
+ Then(
74
+ "User expects {int} th of {string} should be empty",
75
+ async function (order, elements) {
76
+ const nthElement = await frame.nth(elements, order);
77
+ await assert.shouldBeEmpty(nthElement);
78
+ },
79
+ );
80
+
81
+ // Check if a selector should be enabled
82
+ Then("User expects {string} should be enabled", async function (selector) {
83
+ await assert.shouldBeEnabled(selector);
84
+ });
85
+
86
+ Then(
87
+ "User expects {int} th of {string} should be enabled",
88
+ async function (order, elements) {
89
+ const nthElement = await frame.nth(elements, order);
90
+ await assert.shouldBeEnabled(nthElement);
91
+ },
92
+ );
93
+
94
+ // Check if a selector should be focused
95
+ Then("User expects {string} should be focused", async function (selector) {
96
+ await assert.shouldBeFocused(selector);
97
+ });
98
+
99
+ Then(
100
+ "User expects {int} th of {string} should be focused",
101
+ async function (order, elements) {
102
+ const nthElement = await frame.nth(elements, order);
103
+ await assert.shouldBeFocused(nthElement);
104
+ },
105
+ );
106
+
107
+ // Check if a selector should be hidden
108
+ Then("User expects {string} should be hidden", async function (selector) {
109
+ await assert.shouldBeHidden(selector);
110
+ });
111
+
112
+ Then(
113
+ "User expects {int} th of {string} should be hidden",
114
+ async function (order, elements) {
115
+ const nthElement = await frame.nth(elements, order);
116
+ await assert.shouldBeHidden(nthElement);
117
+ },
118
+ );
119
+
120
+ // Check if a selector should be in the viewport
121
+ Then(
122
+ "User expects {string} should be on the screen",
123
+ async function (selector) {
124
+ await assert.shouldBeInViewport(selector);
125
+ },
126
+ );
127
+
128
+ Then(
129
+ "User expects {int} th of {string} should be on the screen",
130
+ async function (order, elements) {
131
+ const nthElement = await frame.nth(elements, order);
132
+ await assert.shouldBeInViewport(nthElement);
133
+ },
134
+ );
135
+
136
+ Then(
137
+ "User expects {int} th of {string} should be screen",
138
+ async function (order, elements) {
139
+ const nthElement = await frame.nth(elements, order);
140
+ await assert.shouldBeInViewport(nthElement);
141
+ },
142
+ );
143
+
144
+ // Check if a selector should be visible
145
+ Then("User expects {string} should be visible", async function (selector) {
146
+ await assert.shouldBeVisible(selector);
147
+ });
148
+
149
+ Then(
150
+ "User expects {int} th of {string} should be visible",
151
+ async function (order, elements) {
152
+ const nthElement = await frame.nth(elements, order);
153
+ await assert.shouldBeVisible(nthElement);
154
+ },
155
+ );
156
+
157
+ // Check if a selector should contain specific text
158
+ Then(
159
+ "User expects {string} should have {string} text",
160
+ async function (selector, text) {
161
+ await assert.shouldContainText(selector, text);
162
+ },
163
+ );
164
+
165
+ Then(
166
+ "User expects {int} th of {string} should have {string} text",
167
+ async function (order, elements, text) {
168
+ const nthElement = await frame.nth(elements, order);
169
+ await assert.shouldContainText(nthElement, text);
170
+ },
171
+ );
172
+
173
+ Then(
174
+ "User expects default value of {string} should have {string} text",
175
+ async (selector, text) => {
176
+ const defaultValue = await element(selector).inputValue();
177
+ await expect(defaultValue).toContain(text);
178
+ },
179
+ );
180
+
181
+ Then(
182
+ "User expects default value of {int} th of {string} should have {string} text",
183
+ async function (order, elements, text) {
184
+ const nthElement = await frame.nth(elements, order);
185
+ await assert.toContain(nthElement, text);
186
+ },
187
+ );
188
+
189
+ Then(
190
+ "User expects multiple {string} should have {string} text",
191
+ async (elements, expectedText) => {
192
+ await assert.multipleElementsShouldContainText(elements, expectedText);
193
+ },
194
+ );
195
+
196
+ // Check if a selector should have an accessible description
197
+ Then(
198
+ "User expects {string} should have {string} description",
199
+ async function (selector, description) {
200
+ await assert.shouldHaveAccessibleDescription(selector, description);
201
+ },
202
+ );
203
+
204
+ Then(
205
+ "User expects {int} th of {string} should have {string} description",
206
+ async function (order, elements, text) {
207
+ const nthElement = await frame.nth(elements, order);
208
+ await assert.shouldHaveAccessibleDescription(nthElement, text);
209
+ },
210
+ );
211
+
212
+ // Check if a selector should have an accessible name
213
+ Then(
214
+ "User expects {string} should have {string} name",
215
+ async function (selector, name) {
216
+ await assert.shouldHaveAccessibleName(selector, name);
217
+ },
218
+ );
219
+
220
+ Then(
221
+ "User expects {int} th of {string} should have {string} name",
222
+ async function (order, elements, text) {
223
+ const nthElement = await frame.nth(elements, order);
224
+ await assert.shouldHaveAccessibleName(nthElement, text);
225
+ },
226
+ );
227
+
228
+ // Check if a selector should have a specific attribute with a given value
229
+ Then(
230
+ "User expects {string} should have {string} attribute with {string} value",
231
+ async function (selector, attribute, value) {
232
+ await assert.shouldHaveAttribute(selector, attribute, value);
233
+ },
234
+ );
235
+
236
+ Then(
237
+ "User expects {int} th of {string} should have {string} attribute with {string} value",
238
+ async function (order, elements, attribute, value) {
239
+ const nthElement = await frame.nth(elements, order);
240
+ await assert.shouldHaveAttribute(nthElement, attribute, value);
241
+ },
242
+ );
243
+
244
+ // Check if a selector should have a specific class
245
+ Then(
246
+ "User expects {string} should have {string} class",
247
+ async function (selector, className) {
248
+ await assert.shouldHaveClass(selector, className);
249
+ },
250
+ );
251
+
252
+ Then(
253
+ "User expects {int} th of {string} should have {string} class",
254
+ async function (order, elements, className) {
255
+ const nthElement = await frame.nth(elements, order);
256
+ await assert.shouldHaveClass(nthElement, className);
257
+ },
258
+ );
259
+
260
+ // Check if a selector should have a specific count
261
+ Then(
262
+ "User expects count of {string} should be {int}",
263
+ async function (selector, count) {
264
+ await assert.shouldHaveCount(selector, count);
265
+ },
266
+ );
267
+
268
+ // Check if a selector should have a specific CSS property with a given value
269
+ Then(
270
+ "User expects {string} should have {string} CSS property with {string} value",
271
+ async function (selector, property, value) {
272
+ await assert.shouldHaveCSS(selector, property, value);
273
+ },
274
+ );
275
+
276
+ Then(
277
+ "User expects {int} th of {string} should have {string} CSS property with {string} value",
278
+ async function (order, elements, property, value) {
279
+ const nthElement = await frame.nth(elements, order);
280
+ await assert.shouldHaveCSS(nthElement, property, value);
281
+ },
282
+ );
283
+
284
+ // Check if a selector should have a specific id
285
+ Then(
286
+ "User expects {string} should have {string} id",
287
+ async function (selector, id) {
288
+ await assert.shouldHaveId(selector, id);
289
+ },
290
+ );
291
+
292
+ Then(
293
+ "User expects {int} th of {string} should have {string} id",
294
+ async function (order, elements, id) {
295
+ const nthElement = await frame.nth(elements, order);
296
+ await assert.shouldHaveId(nthElement, id);
297
+ },
298
+ );
299
+
300
+ // Check if a selector should have a specific JavaScript property with a given value
301
+ Then(
302
+ "User expects {string} should have {string} JavaScript property with {string} value",
303
+ async function (selector, property, value) {
304
+ await assert.shouldHaveJSProperty(selector, property, value);
305
+ },
306
+ );
307
+
308
+ Then(
309
+ "User expects {int} th of {string} should have {string} JavaScript property with {string} value",
310
+ async function (order, elements, property, value) {
311
+ const nthElement = await frame.nth(elements, order);
312
+ await assert.shouldHaveJSProperty(nthElement, property, value);
313
+ },
314
+ );
315
+
316
+ // Check if a selector should have a specific role
317
+ Then(
318
+ "User expects {string} should have {string} role",
319
+ async function (selector, role) {
320
+ await assert.shouldHaveRole(selector, role);
321
+ },
322
+ );
323
+
324
+ Then(
325
+ "User expects {int} th of {string} should have {string} role",
326
+ async function (order, elements, role) {
327
+ const nthElement = await frame.nth(elements, order);
328
+ await assert.shouldHaveId(nthElement, role);
329
+ },
330
+ );
331
+
332
+ Then(
333
+ "User expects that full page match with {string} screenshot",
334
+ async function (baselineFilename) {
335
+ await screenComparer(
336
+ baselineFilename,
337
+ (actualPath) =>
338
+ context.page.screenshot({ path: actualPath, fullPage: true }),
339
+ { maxDiffPercent: 0.01 },
340
+ );
341
+ },
342
+ );
343
+
344
+ Then(
345
+ "User expects that full page match with {string} screenshot with {float}% difference",
346
+ async function (baselineFilename, maxDiff) {
347
+ await screenComparer(
348
+ baselineFilename,
349
+ (actualPath) =>
350
+ context.page.screenshot({ path: actualPath, fullPage: true }),
351
+ { maxDiffPercent: maxDiff / 100 },
352
+ );
353
+ },
354
+ );
355
+
356
+ Then(
357
+ "User expects that page match with {string} screenshot",
358
+ async function (baselineFilename) {
359
+ await screenComparer(
360
+ baselineFilename,
361
+ (actualPath) =>
362
+ context.page.screenshot({ path: actualPath, fullPage: false }),
363
+ { maxDiffPercent: 0.01 },
364
+ );
365
+ },
366
+ );
367
+
368
+ Then(
369
+ "User expects that page match with {string} screenshot with {float}% difference",
370
+ async function (baselineFilename, maxDiff) {
371
+ await screenComparer(
372
+ baselineFilename,
373
+ (actualPath) =>
374
+ context.page.screenshot({ path: actualPath, fullPage: false }),
375
+ { maxDiffPercent: maxDiff / 100 },
376
+ );
377
+ },
378
+ );
379
+
380
+ Then(
381
+ "User expects that {string} element match with {string} screenshot",
382
+ async function (selector, baselineFilename) {
383
+ await screenComparer(
384
+ baselineFilename,
385
+ (actualPath) => element(selector).screenshot({ path: actualPath }),
386
+ { maxDiffPercent: 0.01 },
387
+ );
388
+ },
389
+ );
390
+
391
+ Then(
392
+ "User expects that {string} element match with {string} screenshot with {float}% difference",
393
+ async function (selector, baselineFilename, maxDiff) {
394
+ await screenComparer(
395
+ baselineFilename,
396
+ (actualPath) => element(selector).screenshot({ path: actualPath }),
397
+ { maxDiffPercent: maxDiff / 100 },
398
+ );
399
+ },
400
+ );
401
+
402
+
403
+ Then(
404
+ "User expects that {string} screenshot match with {string} screenshot",
405
+ async function (ss1, ss2) {
406
+ await screenComparer(
407
+ ss1,
408
+ null,
409
+ { maxDiffPercent: 0.01, comparePath: ss2 },
410
+ );
411
+ },
412
+ );
413
+
414
+ Then(
415
+ "User expects that {string} screenshot match with {string} screenshot with {float}% difference",
416
+ async function (ss1, ss2, maxDiff) {
417
+ await screenComparer(
418
+ ss1,
419
+ null,
420
+ { maxDiffPercent: maxDiff / 100, comparePath: ss2 },
421
+ );
422
+ },
423
+ );
424
+
425
+ // Check if a selector should have specific text
426
+ Then(
427
+ "User expects {string} should match {string} text",
428
+ async function (selector, text) {
429
+ await assert.shouldHaveText(selector, text);
430
+ },
431
+ );
432
+
433
+ Then(
434
+ "User expects {int} th of {string} should match {string} text",
435
+ async function (order, elements, text) {
436
+ const nthElement = await frame.nth(elements, order);
437
+ await assert.shouldHaveText(nthElement, text);
438
+ },
439
+ );
440
+
441
+ // Check if a selector should have a specific value
442
+ Then(
443
+ "User expects {string} should have {string} value",
444
+ async function (selector, value) {
445
+ await assert.shouldHaveValue(selector, value);
446
+ },
447
+ );
448
+
449
+ Then(
450
+ "User expects {int} th of {string} should have {string} value",
451
+ async function (order, elements, value) {
452
+ const nthElement = await frame.nth(elements, order);
453
+ await assert.shouldHaveValue(nthElement, value);
454
+ },
455
+ );
456
+
457
+ // Check if a selector should have specific values
458
+ Then(
459
+ "User expects {string} should have {string} values",
460
+ async function (selector, values) {
461
+ await assert.shouldHaveValues(selector, values.split(","));
462
+ },
463
+ );
464
+
465
+ // Check if the page should have a screenshot
466
+ Then("User expects the page should have a screenshot", async function () {
467
+ await assert.shouldPageHaveScreenshot();
468
+ });
469
+
470
+ // Check if the page should have a specific title
471
+ Then(
472
+ "User expects the page should have {string} title",
473
+ async function (title) {
474
+ await assert.shouldPageHaveTitle(title);
475
+ },
476
+ );
477
+
478
+ // Check if the page should have a specific URL
479
+ Then("User expects to be in {string} page", async function (url) {
480
+ const URL = await selector(url);
481
+ await assert.shouldPageHaveURL(URL);
482
+ });
483
+
484
+ // Check if a selector should not be attached
485
+ Then("User expects {string} should not be attached", async function (selector) {
486
+ await assert.shouldNotBeAttached(selector);
487
+ });
488
+
489
+ Then(
490
+ "User expects {int} th of {string} should be not be attached",
491
+ async function (order, elements) {
492
+ const nthElement = await frame.nth(elements, order);
493
+ await assert.shouldNotBeAttached(nthElement);
494
+ },
495
+ );
496
+
497
+ // Check if a selector should not be checked
498
+ Then("User expects {string} should not be checked", async function (selector) {
499
+ await assert.shouldNotBeChecked(selector);
500
+ });
501
+
502
+ Then(
503
+ "User expects {int} th of {string} should be not be checked",
504
+ async function (order, elements) {
505
+ const nthElement = await frame.nth(elements, order);
506
+ await assert.shouldNotBeChecked(nthElement);
507
+ },
508
+ );
509
+
510
+ // Check if a selector should not be disabled
511
+ Then("User expects {string} should not be disabled", async function (selector) {
512
+ await assert.shouldNotBeDisabled(selector);
513
+ });
514
+
515
+ Then(
516
+ "User expects {int} th of {string} should be not be disabled",
517
+ async function (order, elements) {
518
+ const nthElement = await frame.nth(elements, order);
519
+ await assert.shouldNotBeDisabled(nthElement);
520
+ },
521
+ );
522
+
523
+ // Check if a selector should not be editable
524
+ Then("User expects {string} should not be editable", async function (selector) {
525
+ await assert.shouldNotBeEditable(selector);
526
+ });
527
+
528
+ Then(
529
+ "User expects {int} th of {string} should be not be editable",
530
+ async function (order, elements) {
531
+ const nthElement = await frame.nth(elements, order);
532
+ await assert.shouldNotBeEditable(nthElement);
533
+ },
534
+ );
535
+
536
+ // Check if a selector should not be empty
537
+ Then("User expects {string} should not be empty", async function (selector) {
538
+ await assert.shouldNotBeEmpty(selector);
539
+ });
540
+
541
+ Then(
542
+ "User expects {int} th of {string} should be not be empty",
543
+ async function (order, elements) {
544
+ const nthElement = await frame.nth(elements, order);
545
+ await assert.shouldNotBeEmpty(nthElement);
546
+ },
547
+ );
548
+
549
+ // Check if a selector should not be enabled
550
+ Then("User expects {string} should not be enabled", async function (selector) {
551
+ await assert.shouldNotBeEnabled(selector);
552
+ });
553
+
554
+ Then(
555
+ "User expects {int} th of {string} should be not be enabled",
556
+ async function (order, elements) {
557
+ const nthElement = await frame.nth(elements, order);
558
+ await assert.shouldNotBeEnabled(nthElement);
559
+ },
560
+ );
561
+
562
+ // Check if a selector should not be focused
563
+ Then("User expects {string} should not be focused", async function (selector) {
564
+ await assert.shouldNotBeFocused(selector);
565
+ });
566
+
567
+ Then(
568
+ "User expects {int} th of {string} should be not be focused",
569
+ async function (order, elements) {
570
+ const nthElement = await frame.nth(elements, order);
571
+ await assert.shouldNotBeFocused(nthElement);
572
+ },
573
+ );
574
+
575
+ // Check if a selector should not be hidden
576
+ Then("User expects {string} should not be hidden", async function (selector) {
577
+ await assert.shouldNotBeHidden(selector);
578
+ });
579
+
580
+ Then(
581
+ "User expects {int} th of {string} should be not be hidden",
582
+ async function (order, elements) {
583
+ const nthElement = await frame.nth(elements, order);
584
+ await assert.shouldNotBeHidden(nthElement);
585
+ },
586
+ );
587
+
588
+ // Check if a selector should not be in the viewport
589
+ Then(
590
+ "User expects {string} should not be on the screen",
591
+ async function (selector) {
592
+ await assert.shouldNotBeInViewport(selector);
593
+ },
594
+ );
595
+
596
+ Then(
597
+ "User expects {int} th of {string} should not be on the screen",
598
+ async function (order, elements) {
599
+ const nthElement = await frame.nth(elements, order);
600
+ await assert.shouldNotBeInViewport(nthElement);
601
+ },
602
+ );
603
+
604
+ // Check if a selector should not be visible
605
+ Then("User expects {string} should not be visible", async function (selector) {
606
+ await assert.shouldNotBeVisible(selector);
607
+ });
608
+
609
+ Then(
610
+ "User expects {int} th of {string} should not be visible",
611
+ async function (order, elements) {
612
+ const nthElement = await frame.nth(elements, order);
613
+ await assert.shouldNotBeVisible(nthElement);
614
+ },
615
+ );
616
+
617
+ // Check if a selector should not contain specific text
618
+ Then(
619
+ "User expects {string} should not have {string} text",
620
+ async function (selector, text) {
621
+ await assert.shouldNotContainText(selector, text);
622
+ },
623
+ );
624
+
625
+ Then(
626
+ "User expects {int} th of {string} should not have {string} text",
627
+ async function (order, elements, text) {
628
+ const nthElement = await frame.nth(elements, order);
629
+ await assert.shouldNotContainText(nthElement, text);
630
+ },
631
+ );
632
+
633
+ // Check if a selector should not have an accessible description
634
+ Then(
635
+ "User expects {string} should not have {string} description",
636
+ async function (selector, description) {
637
+ await assert.shouldNotHaveAccessibleDescription(selector, description);
638
+ },
639
+ );
640
+
641
+ Then(
642
+ "User expects {int} th of {string} should not have {string} description",
643
+ async function (order, elements, text) {
644
+ const nthElement = await frame.nth(elements, order);
645
+ await assert.shouldNotHaveAccessibleDescription(nthElement, text);
646
+ },
647
+ );
648
+
649
+ // Check if a selector should not have an accessible name
650
+ Then(
651
+ "User expects {string} should not have {string} name",
652
+ async function (selector, name) {
653
+ await assert.shouldNotHaveAccessibleName(selector, name);
654
+ },
655
+ );
656
+
657
+ Then(
658
+ "User expects {int} th of {string} should not have {string} name",
659
+ async function (order, elements, text) {
660
+ const nthElement = await frame.nth(elements, order);
661
+ await assert.shouldNotHaveAccessibleName(nthElement, text);
662
+ },
663
+ );
664
+
665
+ // Check if a selector should not have a specific attribute with a given value
666
+ Then(
667
+ "User expects {string} should not have {string} attribute with {string} value",
668
+ async function (selector, attribute, value) {
669
+ await assert.shouldNotHaveAttribute(selector, attribute, value);
670
+ },
671
+ );
672
+
673
+ Then(
674
+ "User expects {int} th of {string} should have {string} attribute with {string} value",
675
+ async function (order, elements, attribute, value) {
676
+ const nthElement = await frame.nth(elements, order);
677
+ await assert.shouldNotHaveAttribute(nthElement, attribute, value);
678
+ },
679
+ );
680
+
681
+ // Check if a selector should not have a specific class
682
+ Then(
683
+ "User expects {string} should not have {string} class",
684
+ async function (selector, className) {
685
+ await assert.shouldNotHaveClass(selector, className);
686
+ },
687
+ );
688
+
689
+ Then(
690
+ "User expects {int} th of {string} should not have {string} class",
691
+ async function (order, elements, text) {
692
+ const nthElement = await frame.nth(elements, order);
693
+ await assert.shouldNotHaveClass(nthElement, text);
694
+ },
695
+ );
696
+
697
+ // Check if a selector should not have a specific count
698
+ Then(
699
+ "User expects count of {string} should not be {int}",
700
+ async function (selector, count) {
701
+ await assert.shouldNotHaveCount(selector, count);
702
+ },
703
+ );
704
+
705
+ // Check if a selector should not have a specific CSS property with a given value
706
+ Then(
707
+ "User expects {string} should not have {string} CSS property with {string} value",
708
+ async function (selector, property, value) {
709
+ await assert.shouldNotHaveCSS(selector, property, value);
710
+ },
711
+ );
712
+
713
+ Then(
714
+ "User expects {int} th of {string} should not have {string} CSS property with {string} value",
715
+ async function (order, elements, property, value) {
716
+ const nthElement = await frame.nth(elements, order);
717
+ await assert.shouldNotHaveCSS(nthElement, property, value);
718
+ },
719
+ );
720
+
721
+ // Check if a selector should not have a specific ID
722
+ Then(
723
+ "User expects {string} should not have {string} id",
724
+ async function (selector, id) {
725
+ await assert.shouldNotHaveId(selector, id);
726
+ },
727
+ );
728
+
729
+ Then(
730
+ "User expects {int} th of {string} should not have {string} id",
731
+ async function (order, elements, text) {
732
+ const nthElement = await frame.nth(elements, order);
733
+ await assert.shouldNotHaveId(nthElement, text);
734
+ },
735
+ );
736
+
737
+ // Check if a selector should not have a specific JavaScript property with a given value
738
+ Then(
739
+ "User expects {string} should not have {string} JavaScript property with {string} value",
740
+ async function (selector, property, value) {
741
+ await assert.shouldNotHaveJSProperty(selector, property, value);
742
+ },
743
+ );
744
+
745
+ Then(
746
+ "User expects {int} th of {string} should not have {string} JavaScript property with {string} value",
747
+ async function (order, elements, property, value) {
748
+ const nthElement = await frame.nth(elements, order);
749
+ await assert.shouldNotHaveJSProperty(nthElement, property, value);
750
+ },
751
+ );
752
+
753
+ // Check if a selector should not have a specific role
754
+ Then(
755
+ "User expects {string} should not have {string} role",
756
+ async function (selector, role) {
757
+ await assert.shouldNotHaveRole(selector, role);
758
+ },
759
+ );
760
+
761
+ Then(
762
+ "User expects {int} th of {string} should not have {string} role",
763
+ async function (order, elements, text) {
764
+ const nthElement = await frame.nth(elements, order);
765
+ await assert.shouldNotHaveRole(nthElement, text);
766
+ },
767
+ );
768
+
769
+ // Check if a selector should not have specific text
770
+ Then(
771
+ "User expects {string} should not match {string} text",
772
+ async function (selector, text) {
773
+ await assert.shouldNotHaveText(selector, text);
774
+ },
775
+ );
776
+
777
+ Then(
778
+ "User expects {int} th of {string} should not have {string} text",
779
+ async function (order, elements, text) {
780
+ const nthElement = await frame.nth(elements, order);
781
+ await assert.shouldNotHaveText(nthElement, text);
782
+ },
783
+ );
784
+
785
+ // Check if a selector should not have a specific value
786
+ Then(
787
+ "User expects {string} should not have {string} value",
788
+ async function (selector, value) {
789
+ await assert.shouldNotHaveValue(selector, value);
790
+ },
791
+ );
792
+
793
+ Then(
794
+ "User expects {int} th of {string} should not have {string} value",
795
+ async function (order, elements, text) {
796
+ const nthElement = await frame.nth(elements, order);
797
+ await assert.shouldNotHaveValue(nthElement, text);
798
+ },
799
+ );
800
+
801
+ // Check if a selector should not have specific values
802
+ Then(
803
+ "User expects {string} should not have {string} values",
804
+ async function (selector, values) {
805
+ await assert.shouldNotHaveValues(selector, values.split(","));
806
+ },
807
+ );
808
+
809
+ // Check if the page should not have a screenshot
810
+ Then("User expects the page should not have a screenshot", async function () {
811
+ await assert.shouldNotPageHaveScreenshot();
812
+ });
813
+
814
+ // Check if the page should not have a specific title
815
+ Then(
816
+ "User expects the page should not have {string} title",
817
+ async function (title) {
818
+ await assert.shouldNotPageHaveTitle(title);
819
+ },
820
+ );
821
+
822
+ // Check if the page should not have a specific URL
823
+ Then("User expects the page url should not be {string}", async function (url) {
824
+ await assert.shouldNotPageHaveURL(url);
825
+ });
826
+
827
+ Then("User is not on {string} page", async function (url) {
828
+ await assert.shouldNotPageHaveURL(url);
829
+ });
830
+
831
+ // Check if a response should not be OK
832
+ Then("The response should not be OK", async function (response) {
833
+ await assert.shouldNotResponseBeOK(response);
834
+ });
835
+
836
+ // Check if a selector's value should be equal to the expected value
837
+ Then(
838
+ "User expects {string} should be {string} text",
839
+ async function (selector, expected) {
840
+ await assert.shouldBe(selector, expected);
841
+ },
842
+ );
843
+
844
+ // Check if a selector's value should be close to the expected value within a precision
845
+ Then(
846
+ "User expects {string} should be close to {float} with precision {int}",
847
+ async function (selector, expected, precision) {
848
+ await assert.shouldBeCloseTo(selector, expected, precision);
849
+ },
850
+ );
851
+
852
+ // Check if a selector's value should be defined
853
+ Then("User expects {string} should be defined", async function (selector) {
854
+ await assert.shouldBeDefined(selector);
855
+ });
856
+
857
+ // Check if a selector's text content should be falsy
858
+ Then("User expects {string} should be falsy", async function (selector) {
859
+ await assert.shouldBeFalsy(selector);
860
+ });
861
+
862
+ // Check if a selector's value should be greater than the expected value
863
+ Then(
864
+ "User expects {string} should be greater than {float}",
865
+ async function (selector, expected) {
866
+ await assert.shouldBeGreaterThan(selector, expected);
867
+ },
868
+ );
869
+
870
+ // Check if a selector's value should be greater than or equal to the expected value
871
+ Then(
872
+ "User expects {string} should be greater than or equal to {float}",
873
+ async function (selector, expected) {
874
+ await assert.shouldBeGreaterThanOrEqual(selector, expected);
875
+ },
876
+ );
877
+
878
+ // Check if a selector's value should be an instance of a specific constructor
879
+ Then(
880
+ "User expects {string} should be an instance of {string}",
881
+ async function (selector, constructor) {
882
+ await assert.shouldBeInstanceOf(selector, constructor);
883
+ },
884
+ );
885
+
886
+ // Check if a selector's value should be less than the expected value
887
+ Then(
888
+ "User expects {string} should be less than {float}",
889
+ async function (selector, expected) {
890
+ await assert.shouldBeLessThan(selector, expected);
891
+ },
892
+ );
893
+
894
+ // Check if a selector's value should be less than or equal to the expected value
895
+ Then(
896
+ "User expects {string} should be less than or equal to {float}",
897
+ async function (selector, expected) {
898
+ await assert.shouldBeLessThanOrEqual(selector, expected);
899
+ },
900
+ );
901
+
902
+ // Check if a selector's value should be NaN
903
+ Then("User expects {string} should be NaN", async function (selector) {
904
+ await assert.shouldBeNaN(selector);
905
+ });
906
+
907
+ // Check if a selector's value should be null
908
+ Then("User expects {string} should be null", async function (selector) {
909
+ await assert.shouldBeNull(selector);
910
+ });
911
+
912
+ // Check if a selector's value should be truthy
913
+ Then("User expects {string} should be truthy", async function (selector) {
914
+ await assert.shouldBeTruthy(selector);
915
+ });
916
+
917
+ // Check if a selector's value should be undefined
918
+ Then("User expects {string} should be undefined", async function (selector) {
919
+ await assert.shouldBeUndefined(selector);
920
+ });
921
+
922
+ // Check if a selector's value should contain a specific substring
923
+ Then(
924
+ "User expects {string} should have {string} substring",
925
+ async function (selector, substring) {
926
+ await assert.shouldContain(selector, substring);
927
+ },
928
+ );
929
+
930
+ // Check if a selector's value should contain an equal value
931
+ Then(
932
+ "User expects {string} should contain equal {string}",
933
+ async function (selector, expected) {
934
+ await assert.shouldContainEqual(selector, expected);
935
+ },
936
+ );
937
+
938
+ // Check if a selector's value should equal the expected value
939
+ Then(
940
+ "User expects {string} should equal {int}",
941
+ async function (selector, expected) {
942
+ await assert.shouldEqual(selector, expected);
943
+ },
944
+ );
945
+
946
+ // Check if a selector's text content should have a specific length
947
+ Then(
948
+ "User expects length of {string} should be {int}",
949
+ async function (selector, length) {
950
+ await assert.shouldHaveLength(selector, length);
951
+ },
952
+ );
953
+
954
+ // Check if a selector's text content should have a specific property
955
+ Then(
956
+ "User expects {string} should have {string} property",
957
+ async function (selector, property) {
958
+ await assert.shouldHaveProperty(selector, property);
959
+ },
960
+ );
961
+
962
+ // Check if a selector's text content should match a specific regex
963
+ Then(
964
+ "User expects {string} should match {string} regex",
965
+ async function (selector, regex) {
966
+ await assert.shouldMatch(selector, new RegExp(regex));
967
+ },
968
+ );
969
+
970
+ // Check if a selector's text content should match a specific object
971
+ Then(
972
+ "User expects {string} should match {string} object",
973
+ async function (selector, object) {
974
+ await assert.shouldMatchObject(selector, JSON.parse(object));
975
+ },
976
+ );
977
+
978
+ // Check if a selector's text content should strictly equal the expected value
979
+ Then(
980
+ "User expects {string} should strictly equal {string}",
981
+ async function (selector, expected) {
982
+ await assert.shouldStrictEqual(selector, expected);
983
+ },
984
+ );
985
+
986
+ // Check if a async function should throw an error
987
+ Then("The async function should throw", async function (fn) {
988
+ await assert.shouldThrow(fn);
989
+ });
990
+
991
+ // Check if the text content of a selector should be an instance of a specific constructor
992
+ Then(
993
+ "User expects {string} should be any instance of {string}",
994
+ async function (selector, constructor) {
995
+ await assert.shouldAny(selector, constructor);
996
+ },
997
+ );
998
+
999
+ // Check if the text content of a selector may be anything (truthy)
1000
+ Then("User expects {string} may be anything", async function (selector) {
1001
+ await assert.shouldAnything(selector);
1002
+ });
1003
+
1004
+ // Check if the text content of a selector should contain any of the specified elements in an array
1005
+ Then(
1006
+ "User expects {string} should contain {string} array elements",
1007
+ async function (selector, elements) {
1008
+ const parsedElements = elements.split(",");
1009
+ await assert.shouldArrayContaining(selector, parsedElements);
1010
+ },
1011
+ );
1012
+
1013
+ // Check if the text content of a selector should be close to the expected value within a precision
1014
+ Then(
1015
+ "User expects {string} should be close to {float} with precision {int}",
1016
+ async function (selector, expected, precision) {
1017
+ await assert.shouldCloseTo(selector, expected, precision);
1018
+ },
1019
+ );
1020
+
1021
+ // Check if the text content of a selector should contain the specified properties in an object
1022
+ Then(
1023
+ "User expects {string} should contain {string} object properties",
1024
+ async function (selector, properties) {
1025
+ const parsedProperties = properties.split(",");
1026
+ await assert.shouldObjectContaining(selector, parsedProperties);
1027
+ },
1028
+ );
1029
+
1030
+ // Check if the text content of a selector should contain a specific substring
1031
+ Then(
1032
+ "User expects {string} should have {string} substring",
1033
+ async function (selector, substring) {
1034
+ await assert.shouldStringContaining(selector, substring);
1035
+ },
1036
+ );
1037
+
1038
+ // Check if the text content of a selector should match a specific regex
1039
+ Then(
1040
+ "User expects {string} should match {string} regex",
1041
+ async function (selector, regex) {
1042
+ await assert.shouldStringMatching(selector, new RegExp(regex));
1043
+ },
1044
+ );
1045
+
1046
+ // Check if a selector's text content should not be equal to the expected value
1047
+ Then(
1048
+ "User expects {string} should not be {string} text",
1049
+ async function (selector, expected) {
1050
+ await assert.shouldNotBe(selector, expected);
1051
+ },
1052
+ );
1053
+
1054
+ // Check if a selector's text content should not be close to the expected value within a precision
1055
+ Then(
1056
+ "User expects {string} should not be close to {float} with precision {int}",
1057
+ async function (selector, expected, precision) {
1058
+ await assert.shouldNotBeCloseTo(selector, expected, precision);
1059
+ },
1060
+ );
1061
+
1062
+ // Check if a selector's text content should not be defined
1063
+ Then("User expects {string} should not be defined", async function (selector) {
1064
+ await assert.shouldNotBeDefined(selector);
1065
+ });
1066
+
1067
+ // Check if a selector's text content should not be falsy
1068
+ Then("User expects {string} should not be falsy", async function (selector) {
1069
+ await assert.shouldNotBeFalsy(selector);
1070
+ });
1071
+
1072
+ // Check if a selector's text content should not be greater than the expected value
1073
+ Then(
1074
+ "User expects {string} should not be greater than {float}",
1075
+ async function (selector, expected) {
1076
+ await assert.shouldNotBeGreaterThan(selector, expected);
1077
+ },
1078
+ );
1079
+
1080
+ // Check if a selector's text content should not be greater than or equal to the expected value
1081
+ Then(
1082
+ "User expects {string} should not be greater than or equal to {float}",
1083
+ async function (selector, expected) {
1084
+ await assert.shouldNotBeGreaterThanOrEqual(selector, expected);
1085
+ },
1086
+ );
1087
+
1088
+ // Check if a selector's text content should not be an instance of a specific constructor
1089
+ Then(
1090
+ "User expects {string} should not be an instance of {string}",
1091
+ async function (selector, constructor) {
1092
+ await assert.shouldNotBeInstanceOf(selector, constructor);
1093
+ },
1094
+ );
1095
+
1096
+ // Check if a selector's text content should not be less than the expected value
1097
+ Then(
1098
+ "User expects {string} should not be less than {float}",
1099
+ async function (selector, expected) {
1100
+ await assert.shouldNotBeLessThan(selector, expected);
1101
+ },
1102
+ );
1103
+
1104
+ // Check if a selector's text content should not be less than or equal to the expected value
1105
+ Then(
1106
+ "User expects {string} should not be less than or equal to {float}",
1107
+ async function (selector, expected) {
1108
+ await assert.shouldNotBeLessThanOrEqual(selector, expected);
1109
+ },
1110
+ );
1111
+
1112
+ // Check if a selector's text content should not be NaN
1113
+ Then("User expects {string} should not be NaN", async function (selector) {
1114
+ await assert.shouldNotBeNaN(selector);
1115
+ });
1116
+
1117
+ // Check if a selector's text content should not be null
1118
+ Then("User expects {string} should not be null", async function (selector) {
1119
+ await assert.shouldNotBeNull(selector);
1120
+ });
1121
+
1122
+ // Check if a selector's text content should not be truthy
1123
+ Then("User expects {string} should not be truthy", async function (selector) {
1124
+ await assert.shouldNotBeTruthy(selector);
1125
+ });
1126
+
1127
+ // Check if a selector's text content should not be undefined
1128
+ Then(
1129
+ "User expects {string} should not be undefined",
1130
+ async function (selector) {
1131
+ await assert.shouldNotBeUndefined(selector);
1132
+ },
1133
+ );
1134
+
1135
+ // Check if a selector's text content should not contain a specific substring
1136
+ Then(
1137
+ "User expects {string} should not have {string} substring",
1138
+ async function (selector, substring) {
1139
+ await assert.shouldNotContain(selector, substring);
1140
+ },
1141
+ );
1142
+
1143
+ // Check if a selector's text content should not contain an equal value
1144
+ Then(
1145
+ "User expects {string} should not contain equal {string}",
1146
+ async function (selector, expected) {
1147
+ await assert.shouldNotContainEqual(selector, expected);
1148
+ },
1149
+ );
1150
+
1151
+ // Check if a selector's text content should not equal the expected value
1152
+ Then(
1153
+ "User expects {string} should not equal {string}",
1154
+ async function (selector, expected) {
1155
+ await assert.shouldNotEqual(selector, expected);
1156
+ },
1157
+ );
1158
+
1159
+ // Check if a selector's text content should not have a specific length
1160
+ Then(
1161
+ "User expects length of {string} should not be {int} ",
1162
+ async function (selector, length) {
1163
+ await assert.shouldNotHaveLength(selector, length);
1164
+ },
1165
+ );
1166
+
1167
+ // Check if a selector's text content should not have a specific property
1168
+ Then(
1169
+ "User expects {string} should not have {string} property",
1170
+ async function (selector, property) {
1171
+ await assert.shouldNotHaveProperty(selector, property);
1172
+ },
1173
+ );
1174
+
1175
+ // Check if a selector's text content should not match a specific regex
1176
+ Then(
1177
+ "User expects {string} should not match {string} regex",
1178
+ async function (selector, regex) {
1179
+ await assert.shouldNotMatch(selector, new RegExp(regex));
1180
+ },
1181
+ );
1182
+
1183
+ // Check if a selector's text content should not match a specific object
1184
+ Then(
1185
+ "User expects {string} should not match {string} object",
1186
+ async function (selector, object) {
1187
+ await assert.shouldNotMatchObject(selector, JSON.parse(object));
1188
+ },
1189
+ );
1190
+
1191
+ // Check if a async function should not throw an error
1192
+ Then("The async function should not throw", async function (fn) {
1193
+ await assert.shouldNotThrow(fn);
1194
+ });
1195
+
1196
+ // Check if a selector's text content should not be any instance of a specific constructor
1197
+ Then(
1198
+ "User expects {string} should not be any instance of {string}",
1199
+ async function (selector, constructor) {
1200
+ await assert.shouldNotAny(selector, constructor);
1201
+ },
1202
+ );
1203
+
1204
+ // Check if a selector's text content may not be anything (falsy)
1205
+ Then("User expects {string} may not be anything", async function (selector) {
1206
+ await assert.shouldNotAnything(selector);
1207
+ });
1208
+
1209
+ // Check if a selector's text content should not contain any of the specified elements in an array
1210
+ Then(
1211
+ "User expects {string} should not contain {string} array elements",
1212
+ async function (selector, elements) {
1213
+ const parsedElements = elements.split(",");
1214
+ await assert.shouldNotArrayContaining(selector, parsedElements);
1215
+ },
1216
+ );
1217
+
1218
+ // Check if a selector's text content should not be close to the expected value within a precision
1219
+ Then(
1220
+ "User expects {string} should not be close to {float} with precision {int}",
1221
+ async function (selector, expected, precision) {
1222
+ await assert.shouldNotCloseTo(selector, expected, precision);
1223
+ },
1224
+ );
1225
+
1226
+ // Check if a selector's text content should not contain the specified properties in an object
1227
+ Then(
1228
+ "User expects {string} should not contain {string} object properties",
1229
+ async function (selector, properties) {
1230
+ const parsedProperties = JSON.parse(properties);
1231
+ await assert.shouldNotObjectContaining(selector, parsedProperties);
1232
+ },
1233
+ );
1234
+
1235
+ // Check if a selector's text content should not contain a specific substring
1236
+ Then(
1237
+ "User expects {string} should not contain {string} substring",
1238
+ async function (selector, substring) {
1239
+ await assert.shouldNotStringContaining(selector, substring);
1240
+ },
1241
+ );
1242
+
1243
+ // Check if a selector's text content should not match a specific regex
1244
+ Then(
1245
+ "User expects {string} should not match {string} regex",
1246
+ async function (selector, regex) {
1247
+ await assert.shouldNotStringMatching(selector, new RegExp(regex));
1248
+ },
1249
+ );
1250
+
1251
+ Then("User expects should have {int} {string}", async (count, elements) => {
1252
+ const elementCount = await frame.count(elements);
1253
+ expect(elementCount).toEqual(count);
1254
+ });
1255
+
1256
+ Then(
1257
+ "User expects that response has {string} field with {string} value",
1258
+ async (field, value) => {
1259
+ extractVarsFromResponse(context.response["Response Body"], field);
1260
+ const varToString = JSON.stringify(context.vars[field]);
1261
+ expect(varToString).toBe(value);
1262
+ },
1263
+ );
1264
+
1265
+ Then(
1266
+ "User expects that {string} should match {string}",
1267
+ async (value1, value2) => {
1268
+ await expect(resolveVariable(value1)).toBe(value2);
1269
+ },
1270
+ );
1271
+
1272
+ Then(
1273
+ "User expects that response body should match {string} schema",
1274
+ async function (expectedSchema) {
1275
+ expectedSchema = await resolveVariable(expectedSchema);
1276
+ if (expectedSchema != "") {
1277
+ const schema = await selector(expectedSchema);
1278
+ const ajv = await new Ajv();
1279
+ const validate = await ajv.compile(schema);
1280
+ const responseBody = await context.response["Response Body"];
1281
+ const valid = await validate(responseBody);
1282
+ await expect(valid).toBe(true);
1283
+ }
1284
+ },
1285
+ );
1286
+
1287
+ Then(
1288
+ "User expects that request should have {int} status code",
1289
+ async function (expectedStatusCode) {
1290
+ expectedStatusCode = await resolveVariable(expectedStatusCode);
1291
+ const actualStatusCode = await context.response.Response.status();
1292
+ expect(actualStatusCode).toBe(expectedStatusCode);
1293
+ },
1294
+ );
1295
+
1296
+ Then(
1297
+ "User expects that response should have {int} status code",
1298
+ async function (expectedStatusCode) {
1299
+ expectedStatusCode = await resolveVariable(expectedStatusCode);
1300
+ const actualStatusCode = await context.response.Response.status();
1301
+ expect(actualStatusCode).toBe(expectedStatusCode);
1302
+ },
1303
+ );