artes 1.7.19 → 1.7.21

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 (49) hide show
  1. package/README.md +781 -781
  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 -435
  8. package/executer.js +266 -266
  9. package/index.js +51 -51
  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 +230 -230
  14. package/src/helper/controller/findDuplicateTestNames.js +69 -69
  15. package/src/helper/controller/getEnvInfo.js +97 -97
  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 +511 -511
  19. package/src/helper/controller/screenComparer.js +96 -96
  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 -193
  25. package/src/helper/executers/projectCreator.js +226 -226
  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 +69 -69
  30. package/src/helper/stepFunctions/APIActions.js +582 -582
  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 +18 -18
  40. package/src/hooks/hooks.js +287 -287
  41. package/src/stepDefinitions/API.steps.js +404 -404
  42. package/src/stepDefinitions/assertions.steps.js +1358 -1351
  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 +374 -374
  47. package/src/stepDefinitions/page.steps.js +71 -71
  48. package/src/stepDefinitions/random.steps.js +199 -199
  49. package/src/stepDefinitions/report.steps.js +5 -5
@@ -1,986 +1,986 @@
1
- const {
2
- expect,
3
- element,
4
- context,
5
- resolveVariable,
6
- } = require("../imports/commons");
7
- const { elementInteractions } = require("./elementInteractions");
8
- const { frame } = require("../stepFunctions/frameActions");
9
-
10
- const assert = {
11
- // Element Assertion
12
- shouldBeAttached: async (selector, options) => {
13
- options = options ?? {};
14
-
15
- await expect(
16
- typeof selector === "string" ? element(selector) : await selector,
17
- ).toBeAttached(options);
18
- },
19
- shouldBeChecked: async (selector, options) => {
20
- options = options ?? {};
21
-
22
- await expect(
23
- typeof selector === "string" ? element(selector) : await selector,
24
- ).toBeChecked(options);
25
- },
26
- shouldBeDisabled: async (selector, options) => {
27
- options = options ?? {};
28
-
29
- await expect(
30
- typeof selector === "string" ? element(selector) : await selector,
31
- ).toBeDisabled(options);
32
- },
33
- shouldBeEditable: async (selector, options) => {
34
- options = options ?? {};
35
-
36
- await expect(
37
- typeof selector === "string" ? element(selector) : await selector,
38
- ).toBeEditable(options);
39
- },
40
- shouldBeEmpty: async (selector, options) => {
41
- options = options ?? {};
42
-
43
- await expect(
44
- typeof selector === "string" ? element(selector) : await selector,
45
- ).toBeEmpty(options);
46
- },
47
- shouldBeEnabled: async (selector, options) => {
48
- options = options ?? {};
49
-
50
- await expect(
51
- typeof selector === "string" ? element(selector) : await selector,
52
- ).toBeEnabled(options);
53
- },
54
- shouldBeFocused: async (selector, options) => {
55
- options = options ?? {};
56
-
57
- await expect(
58
- typeof selector === "string" ? element(selector) : await selector,
59
- ).toBeFocused(options);
60
- },
61
- shouldBeHidden: async (selector, options) => {
62
- options = options ?? {};
63
-
64
- await expect(
65
- typeof selector === "string" ? element(selector) : await selector,
66
- ).toBeHidden(options);
67
- },
68
- shouldBeInViewport: async (selector, options) => {
69
- options = options ?? {};
70
-
71
- await expect(
72
- typeof selector === "string" ? element(selector) : await selector,
73
- ).toBeInViewport(options);
74
- },
75
- shouldBeVisible: async (selector, options) => {
76
- options = options ?? {};
77
-
78
- await expect(
79
- typeof selector === "string" ? element(selector) : await selector,
80
- ).toBeVisible(options);
81
- },
82
- shouldContainText: async (selector, text, options) => {
83
- options = options ?? {};
84
-
85
- text = await resolveVariable(text);
86
-
87
- await expect(
88
- typeof selector === "string" ? element(selector) : await selector,
89
- ).toContainText(text, options);
90
- },
91
- multipleElementsShouldContainText: async (
92
- elements,
93
- expectedText,
94
- options,
95
- ) => {
96
- options = options ?? {};
97
-
98
- expectedText = await resolveVariable(expectedText);
99
-
100
- const count = await frame.count(elements);
101
-
102
- for (let i = 0; i < count; i++) {
103
- await assert.shouldContainText(
104
- frame.nth(elements, i),
105
- expectedText,
106
- options,
107
- );
108
- }
109
- },
110
- shouldHaveAccessibleDescription: async (selector, description, options) => {
111
- options = options ?? {};
112
-
113
- description = await resolveVariable(description);
114
-
115
- await expect(
116
- typeof selector === "string" ? element(selector) : await selector,
117
- ).toHaveAccessibleDescription(description, options);
118
- },
119
- shouldHaveAccessibleName: async (selector, name, options) => {
120
- options = options ?? {};
121
-
122
- name = await resolveVariable(name);
123
-
124
- await expect(
125
- typeof selector === "string" ? element(selector) : await selector,
126
- ).toHaveAccessibleName(name, options);
127
- },
128
- shouldHaveAttribute: async (selector, attribute, value, options) => {
129
- options = options ?? {};
130
-
131
- attribute = await resolveVariable(attribute);
132
- value = await resolveVariable(value);
133
-
134
- await expect(
135
- typeof selector === "string" ? element(selector) : await selector,
136
- ).toHaveAttribute(attribute, value, options);
137
- },
138
- shouldHaveClass: async (selector, className, options) => {
139
- options = options ?? {};
140
-
141
- className = await resolveVariable(className);
142
-
143
- await expect(
144
- typeof selector === "string" ? element(selector) : await selector,
145
- ).toHaveClass(className, options);
146
- },
147
- shouldHaveCount: async (selector, count, options) => {
148
- options = options ?? {};
149
-
150
- count = await resolveVariable(count);
151
-
152
- await expect(
153
- typeof selector === "string" ? element(selector) : await selector,
154
- ).toHaveCount(count, options);
155
- },
156
- shouldHaveCSS: async (selector, property, value, options) => {
157
- options = options ?? {};
158
-
159
- property = await resolveVariable(property);
160
- value = await resolveVariable(value);
161
-
162
- await expect(
163
- typeof selector === "string" ? element(selector) : await selector,
164
- ).toHaveCSS(property, value, options);
165
- },
166
- shouldHaveId: async (selector, id, options) => {
167
- options = options ?? {};
168
-
169
- id = await resolveVariable(id);
170
-
171
- await expect(
172
- typeof selector === "string" ? element(selector) : await selector,
173
- ).toHaveId(id, options);
174
- },
175
- shouldHaveJSProperty: async (selector, property, value, options) => {
176
- options = options ?? {};
177
-
178
- property = await resolveVariable(property);
179
- value = await resolveVariable(value);
180
-
181
- await expect(
182
- typeof selector === "string" ? element(selector) : await selector,
183
- ).toHaveJSProperty(property, value, options);
184
- },
185
- shouldHaveRole: async (selector, role, options) => {
186
- options = options ?? {};
187
-
188
- role = await resolveVariable(role);
189
-
190
- await expect(
191
- typeof selector === "string" ? element(selector) : await selector,
192
- ).toHaveRole(role, options);
193
- },
194
- shouldHaveText: async (selector, text, options) => {
195
- options = options ?? {};
196
-
197
- text = await resolveVariable(text);
198
-
199
- await expect(
200
- typeof selector === "string" ? element(selector) : await selector,
201
- ).toHaveText(text, options);
202
- },
203
- shouldHaveValue: async (selector, value, options) => {
204
- options = options ?? {};
205
-
206
- value = await resolveVariable(value);
207
-
208
- await expect(
209
- typeof selector === "string" ? element(selector) : await selector,
210
- ).toHaveValue(value, options);
211
- },
212
- shouldHaveValues: async (selector, values, options) => {
213
- options = options ?? {};
214
-
215
- values = values.map((value) => resolveVariable(value));
216
-
217
- await expect(
218
- typeof selector === "string" ? element(selector) : await selector,
219
- ).toHaveValues(values, options);
220
- },
221
- shouldPageHaveScreenshot: async (options) => {
222
- options = options ?? {};
223
-
224
- await expect(context.page).toHaveScreenshot(options);
225
- },
226
- shouldPageHaveTitle: async (title, options) => {
227
- options = options ?? {};
228
-
229
- title = await resolveVariable(title);
230
-
231
- await expect(context.page).toHaveTitle(title, options);
232
- },
233
- shouldPageHaveURL: async (url, options) => {
234
- options = options ?? {};
235
-
236
- url = await resolveVariable(url);
237
-
238
- await expect(context.page).toHaveURL(url, options);
239
- },
240
- shouldResponseBeOK: async (response, options) => {
241
- options = options ?? {};
242
-
243
- await expect(response).toBeOK(options);
244
- },
245
-
246
- // Negative Element Assertion
247
- shouldNotBeAttached: async (selector, options) => {
248
- options = options ?? {};
249
-
250
- await expect(
251
- typeof selector === "string" ? element(selector) : await selector,
252
- ).not.toBeAttached(options);
253
- },
254
- shouldNotBeChecked: async (selector, options) => {
255
- options = options ?? {};
256
-
257
- await expect(
258
- typeof selector === "string" ? element(selector) : await selector,
259
- ).not.toBeChecked(options);
260
- },
261
- shouldNotBeDisabled: async (selector, options) => {
262
- options = options ?? {};
263
-
264
- await expect(
265
- typeof selector === "string" ? element(selector) : await selector,
266
- ).not.toBeDisabled(options);
267
- },
268
- shouldNotBeEditable: async (selector, options) => {
269
- options = options ?? {};
270
-
271
- await expect(
272
- typeof selector === "string" ? element(selector) : await selector,
273
- ).not.toBeEditable(options);
274
- },
275
- shouldNotBeEmpty: async (selector, options) => {
276
- options = options ?? {};
277
-
278
- await expect(
279
- typeof selector === "string" ? element(selector) : await selector,
280
- ).not.toBeEmpty(options);
281
- },
282
- shouldNotBeEnabled: async (selector, options) => {
283
- options = options ?? {};
284
-
285
- await expect(
286
- typeof selector === "string" ? element(selector) : await selector,
287
- ).not.toBeEnabled(options);
288
- },
289
- shouldNotBeFocused: async (selector, options) => {
290
- options = options ?? {};
291
-
292
- await expect(
293
- typeof selector === "string" ? element(selector) : await selector,
294
- ).not.toBeFocused(options);
295
- },
296
- shouldNotBeHidden: async (selector, options) => {
297
- options = options ?? {};
298
-
299
- await expect(
300
- typeof selector === "string" ? element(selector) : await selector,
301
- ).not.toBeHidden(options);
302
- },
303
- shouldNotBeInViewport: async (selector, options) => {
304
- options = options ?? {};
305
-
306
- await expect(
307
- typeof selector === "string" ? element(selector) : await selector,
308
- ).not.toBeInViewport(options);
309
- },
310
- shouldNotBeVisible: async (selector, options) => {
311
- options = options ?? {};
312
-
313
- await expect(
314
- typeof selector === "string" ? element(selector) : await selector,
315
- ).not.toBeVisible(options);
316
- },
317
- shouldNotContainText: async (selector, text, options) => {
318
- options = options ?? {};
319
-
320
- text = await resolveVariable(text);
321
-
322
- await expect(
323
- typeof selector === "string" ? element(selector) : await selector,
324
- ).not.toContainText(text, options);
325
- },
326
- shouldNotHaveAccessibleDescription: async (
327
- selector,
328
- description,
329
- options,
330
- ) => {
331
- options = options ?? {};
332
-
333
- description = await resolveVariable(description);
334
-
335
- await expect(
336
- typeof selector === "string" ? element(selector) : await selector,
337
- ).not.toHaveAccessibleDescription(description, options);
338
- },
339
- shouldNotHaveAccessibleName: async (selector, name, options) => {
340
- options = options ?? {};
341
-
342
- name = await resolveVariable(name);
343
-
344
- await expect(
345
- typeof selector === "string" ? element(selector) : await selector,
346
- ).not.toHaveAccessibleName(name, options);
347
- },
348
- shouldNotHaveAttribute: async (selector, attribute, value, options) => {
349
- options = options ?? {};
350
-
351
- attribute = await resolveVariable(attribute);
352
- value = await resolveVariable(value);
353
-
354
- await expect(
355
- typeof selector === "string" ? element(selector) : await selector,
356
- ).not.toHaveAttribute(attribute, value, options);
357
- },
358
- shouldNotHaveClass: async (selector, className, options) => {
359
- options = options ?? {};
360
-
361
- className = await resolveVariable(className);
362
-
363
- await expect(
364
- typeof selector === "string" ? element(selector) : await selector,
365
- ).not.toHaveClass(className, options);
366
- },
367
- shouldNotHaveCount: async (selector, count, options) => {
368
- options = options ?? {};
369
-
370
- count = await resolveVariable(count);
371
-
372
- await expect(
373
- typeof selector === "string" ? element(selector) : await selector,
374
- ).not.toHaveCount(count, options);
375
- },
376
- shouldNotHaveCSS: async (selector, property, value, options) => {
377
- options = options ?? {};
378
-
379
- property = await resolveVariable(property);
380
- value = await resolveVariable(value);
381
-
382
- await expect(
383
- typeof selector === "string" ? element(selector) : await selector,
384
- ).not.toHaveCSS(property, value, options);
385
- },
386
- shouldNotHaveId: async (selector, id, options) => {
387
- options = options ?? {};
388
-
389
- id = await resolveVariable(id);
390
-
391
- await expect(
392
- typeof selector === "string" ? element(selector) : await selector,
393
- ).not.toHaveId(id, options);
394
- },
395
- shouldNotHaveJSProperty: async (selector, property, value, options) => {
396
- options = options ?? {};
397
-
398
- property = await resolveVariable(property);
399
- value = await resolveVariable(value);
400
-
401
- await expect(
402
- typeof selector === "string" ? element(selector) : await selector,
403
- ).not.toHaveJSProperty(property, value, options);
404
- },
405
- shouldNotHaveRole: async (selector, role, options) => {
406
- options = options ?? {};
407
-
408
- role = await resolveVariable(role);
409
-
410
- await expect(
411
- typeof selector === "string" ? element(selector) : await selector,
412
- ).not.toHaveRole(role, options);
413
- },
414
- shouldNotHaveScreenshot: async (selector, options) => {
415
- options = options ?? {};
416
-
417
- await expect(
418
- typeof selector === "string" ? element(selector) : await selector,
419
- ).not.toHaveScreenshot(options);
420
- },
421
- shouldNotHaveText: async (selector, text, options) => {
422
- options = options ?? {};
423
-
424
- text = await resolveVariable(text);
425
-
426
- await expect(
427
- typeof selector === "string" ? element(selector) : await selector,
428
- ).not.toHaveText(text, options);
429
- },
430
- shouldNotHaveValue: async (selector, value, options) => {
431
- options = options ?? {};
432
-
433
- value = await resolveVariable(value);
434
-
435
- await expect(
436
- typeof selector === "string" ? element(selector) : await selector,
437
- ).not.toHaveValue(value, options);
438
- },
439
- shouldNotHaveValues: async (selector, values, options) => {
440
- options = options ?? {};
441
-
442
- values = values.map((value) => resolveVariable(value));
443
-
444
- await expect(
445
- typeof selector === "string" ? element(selector) : await selector,
446
- ).not.toHaveValues(values, options);
447
- },
448
- shouldNotPageHaveScreenshot: async (options) => {
449
- options = options ?? {};
450
-
451
- await expect(context.page).not.toHaveScreenshot(options);
452
- },
453
- shouldNotPageHaveTitle: async (title, options) => {
454
- options = options ?? {};
455
-
456
- title = await resolveVariable(title);
457
-
458
- await expect(context.page).not.toHaveTitle(title, options);
459
- },
460
- shouldNotPageHaveURL: async (url, options) => {
461
- options = options ?? {};
462
-
463
- url = await resolveVariable(url);
464
-
465
- await expect(context.page).not.toHaveURL(url, options);
466
- },
467
- shouldNotResponseBeOK: async (response, options) => {
468
- options = options ?? {};
469
-
470
- await expect(response).not.toBeOK(options);
471
- },
472
- // Value Assertion
473
-
474
- shouldBe: async (selector, expected, options) => {
475
- options = options ?? {};
476
-
477
- expected = await resolveVariable(expected);
478
-
479
- await expect(await elementInteractions.textContent(selector)).toBe(
480
- expected,
481
- options,
482
- );
483
- },
484
- shouldBeCloseTo: async (selector, expected, precision, options) => {
485
- options = options ?? {};
486
-
487
- expected = await resolveVariable(expected);
488
- precision = await resolveVariable(precision);
489
-
490
- await expect(
491
- Number(await elementInteractions.textContent(selector)),
492
- ).toBeCloseTo(expected, precision, options);
493
- },
494
- shouldBeDefined: async (selector, options) => {
495
- options = options ?? {};
496
-
497
- await expect(await elementInteractions.textContent(selector)).toBeDefined(
498
- options,
499
- );
500
- },
501
- shouldBeFalsy: async (selector, options) => {
502
- options = options ?? {};
503
-
504
- await expect(await elementInteractions.textContent(selector)).toBeFalsy(
505
- options,
506
- );
507
- },
508
- shouldBeGreaterThan: async (selector, expected, options) => {
509
- options = options ?? {};
510
-
511
- expected = await resolveVariable(expected);
512
-
513
- await expect(
514
- Number(await elementInteractions.textContent(selector)),
515
- ).toBeGreaterThan(expected, options);
516
- },
517
- shouldBeGreaterThanOrEqual: async (selector, expected, options) => {
518
- options = options ?? {};
519
-
520
- expected = await resolveVariable(expected);
521
-
522
- await expect(
523
- Number(await elementInteractions.textContent(selector)),
524
- ).toBeGreaterThanOrEqual(expected, options);
525
- },
526
- shouldBeInstanceOf: async (selector, constructor, options) => {
527
- options = options ?? {};
528
-
529
- constructor = await resolveVariable(constructor);
530
-
531
- await expect(
532
- await elementInteractions.textContent(selector),
533
- ).toBeInstanceOf(constructor, options);
534
- },
535
- shouldBeLessThan: async (selector, expected, options) => {
536
- options = options ?? {};
537
-
538
- expected = await resolveVariable(expected);
539
-
540
- await expect(
541
- Number(await elementInteractions.textContent(selector)),
542
- ).toBeLessThan(expected, options);
543
- },
544
- shouldBeLessThanOrEqual: async (selector, expected, options) => {
545
- options = options ?? {};
546
-
547
- expected = await resolveVariable(expected);
548
-
549
- await expect(
550
- Number(await elementInteractions.textContent(selector)),
551
- ).toBeLessThanOrEqual(expected, options);
552
- },
553
- shouldBeNaN: async (selector, options) => {
554
- options = options ?? {};
555
-
556
- await expect(
557
- Number(await elementInteractions.textContent(selector)),
558
- ).toBeNaN(options);
559
- },
560
- shouldBeNull: async (selector, options) => {
561
- options = options ?? {};
562
-
563
- await expect(await elementInteractions.textContent(selector)).toBeNull(
564
- options,
565
- );
566
- },
567
- shouldBeTruthy: async (selector, options) => {
568
- options = options ?? {};
569
-
570
- await expect(await elementInteractions.textContent(selector)).toBeTruthy(
571
- options,
572
- );
573
- },
574
- shouldBeUndefined: async (selector, options) => {
575
- options = options ?? {};
576
-
577
- await expect(await elementInteractions.textContent(selector)).toBeUndefined(
578
- options,
579
- );
580
- },
581
- shouldContain: async (selector, substring, options) => {
582
- options = options ?? {};
583
-
584
- await expect(await elementInteractions.textContent(selector)).toContain(
585
- substring,
586
- options,
587
- );
588
- },
589
- shouldContainEqual: async (selector, expected, options) => {
590
- options = options ?? {};
591
-
592
- expected = await resolveVariable(expected);
593
-
594
- await expect(
595
- await elementInteractions.textContent(selector),
596
- ).toContainEqual(expected, options);
597
- },
598
- shouldEqual: async (selector, expected, options) => {
599
- options = options ?? {};
600
-
601
- expected = await resolveVariable(expected);
602
-
603
- await expect(
604
- Number(await elementInteractions.textContent(selector)),
605
- ).toEqual(expected, options);
606
- },
607
- shouldHaveLength: async (selector, length, options) => {
608
- options = options ?? {};
609
-
610
- length = await resolveVariable(length);
611
-
612
- await expect(await elementInteractions.textContent(selector)).toHaveLength(
613
- length,
614
- options,
615
- );
616
- },
617
- shouldHaveProperty: async (selector, property, options) => {
618
- options = options ?? {};
619
-
620
- property = await resolveVariable(property);
621
-
622
- await expect(
623
- await elementInteractions.textContent(selector),
624
- ).toHaveProperty(property, options);
625
- },
626
- shouldMatch: async (selector, regex, options) => {
627
- options = options ?? {};
628
-
629
- regex = await resolveVariable(regex);
630
-
631
- await expect(await elementInteractions.textContent(selector)).toMatch(
632
- regex,
633
- options,
634
- );
635
- },
636
- shouldMatchObject: async (selector, object, options) => {
637
- options = options ?? {};
638
-
639
- object = await resolveVariable(object);
640
-
641
- await expect(await elementInteractions.textContent(selector)).toMatchObject(
642
- object,
643
- options,
644
- );
645
- },
646
- shouldStrictEqual: async (selector, expected, options) => {
647
- options = options ?? {};
648
-
649
- expected = await resolveVariable(expected);
650
-
651
- await expect(
652
- Number(await elementInteractions.textContent(selector)),
653
- ).toStrictEqual(expected, options);
654
- },
655
- shouldThrow: async (fn, options) => {
656
- options = options ?? {};
657
-
658
- fn = await resolveVariable(fn);
659
-
660
- await expect(fn).toThrow(options);
661
- },
662
- shouldAny: async (selector, constructor, options) => {
663
- options = options ?? {};
664
-
665
- constructor = await resolveVariable(constructor);
666
-
667
- await expect(
668
- await elementInteractions.textContent(selector),
669
- ).any.toBeInstanceOf(constructor, options);
670
- },
671
- shouldAnything: async (selector, options) => {
672
- options = options ?? {};
673
-
674
- await expect(await elementInteractions.textContent(selector)).anything(
675
- options,
676
- );
677
- },
678
- shouldArrayContaining: async (selector, elements, options) => {
679
- options = options ?? {};
680
-
681
- elements = elements.map((element) => resolveVariable(element));
682
-
683
- await expect(await elementInteractions.textContent(selector)).toEqual(
684
- expect.arrayContaining(elements),
685
- options,
686
- );
687
- },
688
- shouldCloseTo: async (selector, expected, precision, options) => {
689
- options = options ?? {};
690
-
691
- expected = await resolveVariable(expected);
692
- precision = await resolveVariable(precision);
693
-
694
- await expect(
695
- Number(await elementInteractions.textContent(selector)),
696
- ).toBeCloseTo(expected, precision, options);
697
- },
698
- shouldObjectContaining: async (selector, properties, options) => {
699
- options = options ?? {};
700
-
701
- properties = await resolveVariable(properties);
702
-
703
- await expect(await elementInteractions.textContent(selector)).toEqual(
704
- expect.objectContaining(properties),
705
- options,
706
- );
707
- },
708
- shouldStringContaining: async (selector, substring, options) => {
709
- options = options ?? {};
710
-
711
- substring = await resolveVariable(substring);
712
-
713
- await expect(await elementInteractions.textContent(selector)).toEqual(
714
- expect.stringContaining(substring),
715
- options,
716
- );
717
- },
718
- shouldStringMatching: async (selector, regex, options) => {
719
- options = options ?? {};
720
-
721
- regex = await resolveVariable(regex);
722
-
723
- await expect(await elementInteractions.textContent(selector)).toEqual(
724
- expect.stringMatching(regex),
725
- options,
726
- );
727
- },
728
-
729
- // Negative Value Assertion
730
- shouldNotBe: async (selector, expected, options) => {
731
- options = options ?? {};
732
-
733
- expected = await resolveVariable(expected);
734
-
735
- await expect(await elementInteractions.textContent(selector)).not.toBe(
736
- expected,
737
- options,
738
- );
739
- },
740
- shouldNotBeCloseTo: async (selector, expected, precision, options) => {
741
- options = options ?? {};
742
-
743
- expected = await resolveVariable(expected);
744
- precision = await resolveVariable(precision);
745
-
746
- await expect(
747
- Number(await elementInteractions.textContent(selector)),
748
- ).not.toBeCloseTo(expected, precision, options);
749
- },
750
- shouldNotBeDefined: async (selector, options) => {
751
- options = options ?? {};
752
-
753
- await expect(
754
- await elementInteractions.textContent(selector),
755
- ).not.toBeDefined(options);
756
- },
757
- shouldNotBeFalsy: async (selector, options) => {
758
- options = options ?? {};
759
-
760
- await expect(await elementInteractions.textContent(selector)).not.toBeFalsy(
761
- options,
762
- );
763
- },
764
- shouldNotBeGreaterThan: async (selector, expected, options) => {
765
- options = options ?? {};
766
-
767
- expected = await resolveVariable(expected);
768
-
769
- await expect(
770
- await elementInteractions.textContent(selector),
771
- ).not.toBeGreaterThan(expected, options);
772
- },
773
- shouldNotBeGreaterThanOrEqual: async (selector, expected, options) => {
774
- options = options ?? {};
775
-
776
- expected = await resolveVariable(expected);
777
-
778
- await expect(
779
- Number(await elementInteractions.textContent(selector)),
780
- ).not.toBeGreaterThanOrEqual(expected, options);
781
- },
782
- shouldNotBeInstanceOf: async (selector, constructor, options) => {
783
- options = options ?? {};
784
-
785
- constructor = await resolveVariable(constructor);
786
-
787
- await expect(
788
- await elementInteractions.textContent(selector),
789
- ).not.toBeInstanceOf(constructor, options);
790
- },
791
- shouldNotBeLessThan: async (selector, expected, options) => {
792
- options = options ?? {};
793
-
794
- expected = await resolveVariable(expected);
795
-
796
- await expect(
797
- Number(await elementInteractions.textContent(selector)),
798
- ).not.toBeLessThan(expected, options);
799
- },
800
- shouldNotBeLessThanOrEqual: async (selector, expected, options) => {
801
- options = options ?? {};
802
-
803
- expected = await resolveVariable(expected);
804
-
805
- await expect(
806
- Number(await elementInteractions.textContent(selector)),
807
- ).not.toBeLessThanOrEqual(expected, options);
808
- },
809
- shouldNotBeNaN: async (selector, options) => {
810
- options = options ?? {};
811
-
812
- await expect(
813
- Number(await elementInteractions.textContent(selector)),
814
- ).not.toBeNaN(options);
815
- },
816
- shouldNotBeNull: async (selector, options) => {
817
- options = options ?? {};
818
-
819
- await expect(await elementInteractions.textContent(selector)).not.toBeNull(
820
- options,
821
- );
822
- },
823
- shouldNotBeTruthy: async (selector, options) => {
824
- options = options ?? {};
825
-
826
- await expect(
827
- await elementInteractions.textContent(selector),
828
- ).not.toBeTruthy(options);
829
- },
830
- shouldNotBeUndefined: async (selector, options) => {
831
- options = options ?? {};
832
-
833
- await expect(
834
- await elementInteractions.textContent(selector),
835
- ).not.toBeUndefined(options);
836
- },
837
- shouldNotContain: async (selector, substring, options) => {
838
- options = options ?? {};
839
-
840
- substring = await resolveVariable(substring);
841
-
842
- await expect(await elementInteractions.textContent(selector)).not.toContain(
843
- substring,
844
- options,
845
- );
846
- },
847
- shouldNotContainEqual: async (selector, expected, options) => {
848
- options = options ?? {};
849
-
850
- expected = await resolveVariable(expected);
851
-
852
- await expect(
853
- Number(await elementInteractions.textContent(selector)),
854
- ).not.toContainEqual(expected, options);
855
- },
856
- shouldNotEqual: async (selector, expected, options) => {
857
- options = options ?? {};
858
-
859
- expected = await resolveVariable(expected);
860
-
861
- await expect(
862
- Number(await elementInteractions.textContent(selector)),
863
- ).not.toEqual(expected, options);
864
- },
865
- shouldNotHaveLength: async (selector, length, options) => {
866
- options = options ?? {};
867
-
868
- length = await resolveVariable(length);
869
-
870
- await expect(
871
- await elementInteractions.textContent(selector),
872
- ).not.toHaveLength(length, options);
873
- },
874
- shouldNotHaveProperty: async (selector, property, options) => {
875
- options = options ?? {};
876
-
877
- property = await resolveVariable(property);
878
-
879
- await expect(
880
- await elementInteractions.textContent(selector),
881
- ).not.toHaveProperty(property, options);
882
- },
883
- shouldNotMatch: async (selector, regex, options) => {
884
- options = options ?? {};
885
-
886
- regex = await resolveVariable(regex);
887
-
888
- await expect(await elementInteractions.textContent(selector)).not.toMatch(
889
- regex,
890
- options,
891
- );
892
- },
893
- shouldNotMatchObject: async (selector, object, options) => {
894
- options = options ?? {};
895
-
896
- object = await resolveVariable(object);
897
-
898
- await expect(
899
- await elementInteractions.textContent(selector),
900
- ).not.toMatchObject(object, options);
901
- },
902
- shouldNotStrictEqual: async (selector, expected, options) => {
903
- options = options ?? {};
904
-
905
- expected = await resolveVariable(expected);
906
-
907
- await expect(
908
- Number(await elementInteractions.textContent(selector)),
909
- ).not.toStrictEqual(expected, options);
910
- },
911
- shouldNotThrow: async (fn, options) => {
912
- options = options ?? {};
913
-
914
- fn = await resolveVariable(fn);
915
-
916
- await expect(fn).not.toThrow(options);
917
- },
918
- shouldNotAny: async (selector, constructor, options) => {
919
- options = options ?? {};
920
-
921
- constructor = await await resolveVariable(constructor);
922
-
923
- await expect(
924
- await elementInteractions.textContent(selector),
925
- ).any.toBeInstanceOf(constructor, options);
926
- },
927
- shouldNotAnything: async (selector, options) => {
928
- options = options ?? {};
929
-
930
- await expect(await elementInteractions.textContent(selector)).not.anything(
931
- options,
932
- );
933
- },
934
- shouldNotArrayContaining: async (selector, elements, options) => {
935
- options = options ?? {};
936
-
937
- elements = elements.map((element) => resolveVariable(element));
938
-
939
- await expect(await elementInteractions.textContent(selector)).not.toEqual(
940
- expect.arrayContaining(elements),
941
- options,
942
- );
943
- },
944
- shouldNotCloseTo: async (selector, expected, precision, options) => {
945
- options = options ?? {};
946
-
947
- expected = await resolveVariable(expected);
948
- precision = await resolveVariable(precision);
949
-
950
- await expect(
951
- Number(await elementInteractions.textContent(selector)),
952
- ).not.toBeCloseTo(expected, precision, options);
953
- },
954
- shouldNotObjectContaining: async (selector, properties, options) => {
955
- options = options ?? {};
956
-
957
- properties = await resolveVariable(properties);
958
-
959
- await expect(await elementInteractions.textContent(selector)).not.toEqual(
960
- expect.objectContaining(properties),
961
- options,
962
- );
963
- },
964
- shouldNotStringContaining: async (selector, substring, options) => {
965
- options = options ?? {};
966
-
967
- substring = await resolveVariable(substring);
968
-
969
- await expect(await elementInteractions.textContent(selector)).not.toEqual(
970
- expect.stringContaining(substring),
971
- options,
972
- );
973
- },
974
- shouldNotStringMatching: async (selector, regex, options) => {
975
- options = options ?? {};
976
-
977
- regex = await resolveVariable(regex);
978
-
979
- await expect(await elementInteractions.textContent(selector)).not.toEqual(
980
- expect.stringMatching(regex),
981
- options,
982
- );
983
- },
984
- };
985
-
986
- module.exports = { assert };
1
+ const {
2
+ expect,
3
+ element,
4
+ context,
5
+ resolveVariable,
6
+ } = require("../imports/commons");
7
+ const { elementInteractions } = require("./elementInteractions");
8
+ const { frame } = require("../stepFunctions/frameActions");
9
+
10
+ const assert = {
11
+ // Element Assertion
12
+ shouldBeAttached: async (selector, options) => {
13
+ options = options ?? {};
14
+
15
+ await expect(
16
+ typeof selector === "string" ? element(selector) : await selector,
17
+ ).toBeAttached(options);
18
+ },
19
+ shouldBeChecked: async (selector, options) => {
20
+ options = options ?? {};
21
+
22
+ await expect(
23
+ typeof selector === "string" ? element(selector) : await selector,
24
+ ).toBeChecked(options);
25
+ },
26
+ shouldBeDisabled: async (selector, options) => {
27
+ options = options ?? {};
28
+
29
+ await expect(
30
+ typeof selector === "string" ? element(selector) : await selector,
31
+ ).toBeDisabled(options);
32
+ },
33
+ shouldBeEditable: async (selector, options) => {
34
+ options = options ?? {};
35
+
36
+ await expect(
37
+ typeof selector === "string" ? element(selector) : await selector,
38
+ ).toBeEditable(options);
39
+ },
40
+ shouldBeEmpty: async (selector, options) => {
41
+ options = options ?? {};
42
+
43
+ await expect(
44
+ typeof selector === "string" ? element(selector) : await selector,
45
+ ).toBeEmpty(options);
46
+ },
47
+ shouldBeEnabled: async (selector, options) => {
48
+ options = options ?? {};
49
+
50
+ await expect(
51
+ typeof selector === "string" ? element(selector) : await selector,
52
+ ).toBeEnabled(options);
53
+ },
54
+ shouldBeFocused: async (selector, options) => {
55
+ options = options ?? {};
56
+
57
+ await expect(
58
+ typeof selector === "string" ? element(selector) : await selector,
59
+ ).toBeFocused(options);
60
+ },
61
+ shouldBeHidden: async (selector, options) => {
62
+ options = options ?? {};
63
+
64
+ await expect(
65
+ typeof selector === "string" ? element(selector) : await selector,
66
+ ).toBeHidden(options);
67
+ },
68
+ shouldBeInViewport: async (selector, options) => {
69
+ options = options ?? {};
70
+
71
+ await expect(
72
+ typeof selector === "string" ? element(selector) : await selector,
73
+ ).toBeInViewport(options);
74
+ },
75
+ shouldBeVisible: async (selector, options) => {
76
+ options = options ?? {};
77
+
78
+ await expect(
79
+ typeof selector === "string" ? element(selector) : await selector,
80
+ ).toBeVisible(options);
81
+ },
82
+ shouldContainText: async (selector, text, options) => {
83
+ options = options ?? {};
84
+
85
+ text = await resolveVariable(text);
86
+
87
+ await expect(
88
+ typeof selector === "string" ? element(selector) : await selector,
89
+ ).toContainText(text, options);
90
+ },
91
+ multipleElementsShouldContainText: async (
92
+ elements,
93
+ expectedText,
94
+ options,
95
+ ) => {
96
+ options = options ?? {};
97
+
98
+ expectedText = await resolveVariable(expectedText);
99
+
100
+ const count = await frame.count(elements);
101
+
102
+ for (let i = 0; i < count; i++) {
103
+ await assert.shouldContainText(
104
+ frame.nth(elements, i),
105
+ expectedText,
106
+ options,
107
+ );
108
+ }
109
+ },
110
+ shouldHaveAccessibleDescription: async (selector, description, options) => {
111
+ options = options ?? {};
112
+
113
+ description = await resolveVariable(description);
114
+
115
+ await expect(
116
+ typeof selector === "string" ? element(selector) : await selector,
117
+ ).toHaveAccessibleDescription(description, options);
118
+ },
119
+ shouldHaveAccessibleName: async (selector, name, options) => {
120
+ options = options ?? {};
121
+
122
+ name = await resolveVariable(name);
123
+
124
+ await expect(
125
+ typeof selector === "string" ? element(selector) : await selector,
126
+ ).toHaveAccessibleName(name, options);
127
+ },
128
+ shouldHaveAttribute: async (selector, attribute, value, options) => {
129
+ options = options ?? {};
130
+
131
+ attribute = await resolveVariable(attribute);
132
+ value = await resolveVariable(value);
133
+
134
+ await expect(
135
+ typeof selector === "string" ? element(selector) : await selector,
136
+ ).toHaveAttribute(attribute, value, options);
137
+ },
138
+ shouldHaveClass: async (selector, className, options) => {
139
+ options = options ?? {};
140
+
141
+ className = await resolveVariable(className);
142
+
143
+ await expect(
144
+ typeof selector === "string" ? element(selector) : await selector,
145
+ ).toHaveClass(className, options);
146
+ },
147
+ shouldHaveCount: async (selector, count, options) => {
148
+ options = options ?? {};
149
+
150
+ count = await resolveVariable(count);
151
+
152
+ await expect(
153
+ typeof selector === "string" ? element(selector) : await selector,
154
+ ).toHaveCount(count, options);
155
+ },
156
+ shouldHaveCSS: async (selector, property, value, options) => {
157
+ options = options ?? {};
158
+
159
+ property = await resolveVariable(property);
160
+ value = await resolveVariable(value);
161
+
162
+ await expect(
163
+ typeof selector === "string" ? element(selector) : await selector,
164
+ ).toHaveCSS(property, value, options);
165
+ },
166
+ shouldHaveId: async (selector, id, options) => {
167
+ options = options ?? {};
168
+
169
+ id = await resolveVariable(id);
170
+
171
+ await expect(
172
+ typeof selector === "string" ? element(selector) : await selector,
173
+ ).toHaveId(id, options);
174
+ },
175
+ shouldHaveJSProperty: async (selector, property, value, options) => {
176
+ options = options ?? {};
177
+
178
+ property = await resolveVariable(property);
179
+ value = await resolveVariable(value);
180
+
181
+ await expect(
182
+ typeof selector === "string" ? element(selector) : await selector,
183
+ ).toHaveJSProperty(property, value, options);
184
+ },
185
+ shouldHaveRole: async (selector, role, options) => {
186
+ options = options ?? {};
187
+
188
+ role = await resolveVariable(role);
189
+
190
+ await expect(
191
+ typeof selector === "string" ? element(selector) : await selector,
192
+ ).toHaveRole(role, options);
193
+ },
194
+ shouldHaveText: async (selector, text, options) => {
195
+ options = options ?? {};
196
+
197
+ text = await resolveVariable(text);
198
+
199
+ await expect(
200
+ typeof selector === "string" ? element(selector) : await selector,
201
+ ).toHaveText(text, options);
202
+ },
203
+ shouldHaveValue: async (selector, value, options) => {
204
+ options = options ?? {};
205
+
206
+ value = await resolveVariable(value);
207
+
208
+ await expect(
209
+ typeof selector === "string" ? element(selector) : await selector,
210
+ ).toHaveValue(value, options);
211
+ },
212
+ shouldHaveValues: async (selector, values, options) => {
213
+ options = options ?? {};
214
+
215
+ values = values.map((value) => resolveVariable(value));
216
+
217
+ await expect(
218
+ typeof selector === "string" ? element(selector) : await selector,
219
+ ).toHaveValues(values, options);
220
+ },
221
+ shouldPageHaveScreenshot: async (options) => {
222
+ options = options ?? {};
223
+
224
+ await expect(context.page).toHaveScreenshot(options);
225
+ },
226
+ shouldPageHaveTitle: async (title, options) => {
227
+ options = options ?? {};
228
+
229
+ title = await resolveVariable(title);
230
+
231
+ await expect(context.page).toHaveTitle(title, options);
232
+ },
233
+ shouldPageHaveURL: async (url, options) => {
234
+ options = options ?? {};
235
+
236
+ url = await resolveVariable(url);
237
+
238
+ await expect(context.page).toHaveURL(url, options);
239
+ },
240
+ shouldResponseBeOK: async (response, options) => {
241
+ options = options ?? {};
242
+
243
+ await expect(response).toBeOK(options);
244
+ },
245
+
246
+ // Negative Element Assertion
247
+ shouldNotBeAttached: async (selector, options) => {
248
+ options = options ?? {};
249
+
250
+ await expect(
251
+ typeof selector === "string" ? element(selector) : await selector,
252
+ ).not.toBeAttached(options);
253
+ },
254
+ shouldNotBeChecked: async (selector, options) => {
255
+ options = options ?? {};
256
+
257
+ await expect(
258
+ typeof selector === "string" ? element(selector) : await selector,
259
+ ).not.toBeChecked(options);
260
+ },
261
+ shouldNotBeDisabled: async (selector, options) => {
262
+ options = options ?? {};
263
+
264
+ await expect(
265
+ typeof selector === "string" ? element(selector) : await selector,
266
+ ).not.toBeDisabled(options);
267
+ },
268
+ shouldNotBeEditable: async (selector, options) => {
269
+ options = options ?? {};
270
+
271
+ await expect(
272
+ typeof selector === "string" ? element(selector) : await selector,
273
+ ).not.toBeEditable(options);
274
+ },
275
+ shouldNotBeEmpty: async (selector, options) => {
276
+ options = options ?? {};
277
+
278
+ await expect(
279
+ typeof selector === "string" ? element(selector) : await selector,
280
+ ).not.toBeEmpty(options);
281
+ },
282
+ shouldNotBeEnabled: async (selector, options) => {
283
+ options = options ?? {};
284
+
285
+ await expect(
286
+ typeof selector === "string" ? element(selector) : await selector,
287
+ ).not.toBeEnabled(options);
288
+ },
289
+ shouldNotBeFocused: async (selector, options) => {
290
+ options = options ?? {};
291
+
292
+ await expect(
293
+ typeof selector === "string" ? element(selector) : await selector,
294
+ ).not.toBeFocused(options);
295
+ },
296
+ shouldNotBeHidden: async (selector, options) => {
297
+ options = options ?? {};
298
+
299
+ await expect(
300
+ typeof selector === "string" ? element(selector) : await selector,
301
+ ).not.toBeHidden(options);
302
+ },
303
+ shouldNotBeInViewport: async (selector, options) => {
304
+ options = options ?? {};
305
+
306
+ await expect(
307
+ typeof selector === "string" ? element(selector) : await selector,
308
+ ).not.toBeInViewport(options);
309
+ },
310
+ shouldNotBeVisible: async (selector, options) => {
311
+ options = options ?? {};
312
+
313
+ await expect(
314
+ typeof selector === "string" ? element(selector) : await selector,
315
+ ).not.toBeVisible(options);
316
+ },
317
+ shouldNotContainText: async (selector, text, options) => {
318
+ options = options ?? {};
319
+
320
+ text = await resolveVariable(text);
321
+
322
+ await expect(
323
+ typeof selector === "string" ? element(selector) : await selector,
324
+ ).not.toContainText(text, options);
325
+ },
326
+ shouldNotHaveAccessibleDescription: async (
327
+ selector,
328
+ description,
329
+ options,
330
+ ) => {
331
+ options = options ?? {};
332
+
333
+ description = await resolveVariable(description);
334
+
335
+ await expect(
336
+ typeof selector === "string" ? element(selector) : await selector,
337
+ ).not.toHaveAccessibleDescription(description, options);
338
+ },
339
+ shouldNotHaveAccessibleName: async (selector, name, options) => {
340
+ options = options ?? {};
341
+
342
+ name = await resolveVariable(name);
343
+
344
+ await expect(
345
+ typeof selector === "string" ? element(selector) : await selector,
346
+ ).not.toHaveAccessibleName(name, options);
347
+ },
348
+ shouldNotHaveAttribute: async (selector, attribute, value, options) => {
349
+ options = options ?? {};
350
+
351
+ attribute = await resolveVariable(attribute);
352
+ value = await resolveVariable(value);
353
+
354
+ await expect(
355
+ typeof selector === "string" ? element(selector) : await selector,
356
+ ).not.toHaveAttribute(attribute, value, options);
357
+ },
358
+ shouldNotHaveClass: async (selector, className, options) => {
359
+ options = options ?? {};
360
+
361
+ className = await resolveVariable(className);
362
+
363
+ await expect(
364
+ typeof selector === "string" ? element(selector) : await selector,
365
+ ).not.toHaveClass(className, options);
366
+ },
367
+ shouldNotHaveCount: async (selector, count, options) => {
368
+ options = options ?? {};
369
+
370
+ count = await resolveVariable(count);
371
+
372
+ await expect(
373
+ typeof selector === "string" ? element(selector) : await selector,
374
+ ).not.toHaveCount(count, options);
375
+ },
376
+ shouldNotHaveCSS: async (selector, property, value, options) => {
377
+ options = options ?? {};
378
+
379
+ property = await resolveVariable(property);
380
+ value = await resolveVariable(value);
381
+
382
+ await expect(
383
+ typeof selector === "string" ? element(selector) : await selector,
384
+ ).not.toHaveCSS(property, value, options);
385
+ },
386
+ shouldNotHaveId: async (selector, id, options) => {
387
+ options = options ?? {};
388
+
389
+ id = await resolveVariable(id);
390
+
391
+ await expect(
392
+ typeof selector === "string" ? element(selector) : await selector,
393
+ ).not.toHaveId(id, options);
394
+ },
395
+ shouldNotHaveJSProperty: async (selector, property, value, options) => {
396
+ options = options ?? {};
397
+
398
+ property = await resolveVariable(property);
399
+ value = await resolveVariable(value);
400
+
401
+ await expect(
402
+ typeof selector === "string" ? element(selector) : await selector,
403
+ ).not.toHaveJSProperty(property, value, options);
404
+ },
405
+ shouldNotHaveRole: async (selector, role, options) => {
406
+ options = options ?? {};
407
+
408
+ role = await resolveVariable(role);
409
+
410
+ await expect(
411
+ typeof selector === "string" ? element(selector) : await selector,
412
+ ).not.toHaveRole(role, options);
413
+ },
414
+ shouldNotHaveScreenshot: async (selector, options) => {
415
+ options = options ?? {};
416
+
417
+ await expect(
418
+ typeof selector === "string" ? element(selector) : await selector,
419
+ ).not.toHaveScreenshot(options);
420
+ },
421
+ shouldNotHaveText: async (selector, text, options) => {
422
+ options = options ?? {};
423
+
424
+ text = await resolveVariable(text);
425
+
426
+ await expect(
427
+ typeof selector === "string" ? element(selector) : await selector,
428
+ ).not.toHaveText(text, options);
429
+ },
430
+ shouldNotHaveValue: async (selector, value, options) => {
431
+ options = options ?? {};
432
+
433
+ value = await resolveVariable(value);
434
+
435
+ await expect(
436
+ typeof selector === "string" ? element(selector) : await selector,
437
+ ).not.toHaveValue(value, options);
438
+ },
439
+ shouldNotHaveValues: async (selector, values, options) => {
440
+ options = options ?? {};
441
+
442
+ values = values.map((value) => resolveVariable(value));
443
+
444
+ await expect(
445
+ typeof selector === "string" ? element(selector) : await selector,
446
+ ).not.toHaveValues(values, options);
447
+ },
448
+ shouldNotPageHaveScreenshot: async (options) => {
449
+ options = options ?? {};
450
+
451
+ await expect(context.page).not.toHaveScreenshot(options);
452
+ },
453
+ shouldNotPageHaveTitle: async (title, options) => {
454
+ options = options ?? {};
455
+
456
+ title = await resolveVariable(title);
457
+
458
+ await expect(context.page).not.toHaveTitle(title, options);
459
+ },
460
+ shouldNotPageHaveURL: async (url, options) => {
461
+ options = options ?? {};
462
+
463
+ url = await resolveVariable(url);
464
+
465
+ await expect(context.page).not.toHaveURL(url, options);
466
+ },
467
+ shouldNotResponseBeOK: async (response, options) => {
468
+ options = options ?? {};
469
+
470
+ await expect(response).not.toBeOK(options);
471
+ },
472
+ // Value Assertion
473
+
474
+ shouldBe: async (selector, expected, options) => {
475
+ options = options ?? {};
476
+
477
+ expected = await resolveVariable(expected);
478
+
479
+ await expect(await elementInteractions.textContent(selector)).toBe(
480
+ expected,
481
+ options,
482
+ );
483
+ },
484
+ shouldBeCloseTo: async (selector, expected, precision, options) => {
485
+ options = options ?? {};
486
+
487
+ expected = await resolveVariable(expected);
488
+ precision = await resolveVariable(precision);
489
+
490
+ await expect(
491
+ Number(await elementInteractions.textContent(selector)),
492
+ ).toBeCloseTo(expected, precision, options);
493
+ },
494
+ shouldBeDefined: async (selector, options) => {
495
+ options = options ?? {};
496
+
497
+ await expect(await elementInteractions.textContent(selector)).toBeDefined(
498
+ options,
499
+ );
500
+ },
501
+ shouldBeFalsy: async (selector, options) => {
502
+ options = options ?? {};
503
+
504
+ await expect(await elementInteractions.textContent(selector)).toBeFalsy(
505
+ options,
506
+ );
507
+ },
508
+ shouldBeGreaterThan: async (selector, expected, options) => {
509
+ options = options ?? {};
510
+
511
+ expected = await resolveVariable(expected);
512
+
513
+ await expect(
514
+ Number(await elementInteractions.textContent(selector)),
515
+ ).toBeGreaterThan(expected, options);
516
+ },
517
+ shouldBeGreaterThanOrEqual: async (selector, expected, options) => {
518
+ options = options ?? {};
519
+
520
+ expected = await resolveVariable(expected);
521
+
522
+ await expect(
523
+ Number(await elementInteractions.textContent(selector)),
524
+ ).toBeGreaterThanOrEqual(expected, options);
525
+ },
526
+ shouldBeInstanceOf: async (selector, constructor, options) => {
527
+ options = options ?? {};
528
+
529
+ constructor = await resolveVariable(constructor);
530
+
531
+ await expect(
532
+ await elementInteractions.textContent(selector),
533
+ ).toBeInstanceOf(constructor, options);
534
+ },
535
+ shouldBeLessThan: async (selector, expected, options) => {
536
+ options = options ?? {};
537
+
538
+ expected = await resolveVariable(expected);
539
+
540
+ await expect(
541
+ Number(await elementInteractions.textContent(selector)),
542
+ ).toBeLessThan(expected, options);
543
+ },
544
+ shouldBeLessThanOrEqual: async (selector, expected, options) => {
545
+ options = options ?? {};
546
+
547
+ expected = await resolveVariable(expected);
548
+
549
+ await expect(
550
+ Number(await elementInteractions.textContent(selector)),
551
+ ).toBeLessThanOrEqual(expected, options);
552
+ },
553
+ shouldBeNaN: async (selector, options) => {
554
+ options = options ?? {};
555
+
556
+ await expect(
557
+ Number(await elementInteractions.textContent(selector)),
558
+ ).toBeNaN(options);
559
+ },
560
+ shouldBeNull: async (selector, options) => {
561
+ options = options ?? {};
562
+
563
+ await expect(await elementInteractions.textContent(selector)).toBeNull(
564
+ options,
565
+ );
566
+ },
567
+ shouldBeTruthy: async (selector, options) => {
568
+ options = options ?? {};
569
+
570
+ await expect(await elementInteractions.textContent(selector)).toBeTruthy(
571
+ options,
572
+ );
573
+ },
574
+ shouldBeUndefined: async (selector, options) => {
575
+ options = options ?? {};
576
+
577
+ await expect(await elementInteractions.textContent(selector)).toBeUndefined(
578
+ options,
579
+ );
580
+ },
581
+ shouldContain: async (selector, substring, options) => {
582
+ options = options ?? {};
583
+
584
+ await expect(await elementInteractions.textContent(selector)).toContain(
585
+ substring,
586
+ options,
587
+ );
588
+ },
589
+ shouldContainEqual: async (selector, expected, options) => {
590
+ options = options ?? {};
591
+
592
+ expected = await resolveVariable(expected);
593
+
594
+ await expect(
595
+ await elementInteractions.textContent(selector),
596
+ ).toContainEqual(expected, options);
597
+ },
598
+ shouldEqual: async (selector, expected, options) => {
599
+ options = options ?? {};
600
+
601
+ expected = await resolveVariable(expected);
602
+
603
+ await expect(
604
+ Number(await elementInteractions.textContent(selector)),
605
+ ).toEqual(expected, options);
606
+ },
607
+ shouldHaveLength: async (selector, length, options) => {
608
+ options = options ?? {};
609
+
610
+ length = await resolveVariable(length);
611
+
612
+ await expect(await elementInteractions.textContent(selector)).toHaveLength(
613
+ length,
614
+ options,
615
+ );
616
+ },
617
+ shouldHaveProperty: async (selector, property, options) => {
618
+ options = options ?? {};
619
+
620
+ property = await resolveVariable(property);
621
+
622
+ await expect(
623
+ await elementInteractions.textContent(selector),
624
+ ).toHaveProperty(property, options);
625
+ },
626
+ shouldMatch: async (selector, regex, options) => {
627
+ options = options ?? {};
628
+
629
+ regex = await resolveVariable(regex);
630
+
631
+ await expect(await elementInteractions.textContent(selector)).toMatch(
632
+ regex,
633
+ options,
634
+ );
635
+ },
636
+ shouldMatchObject: async (selector, object, options) => {
637
+ options = options ?? {};
638
+
639
+ object = await resolveVariable(object);
640
+
641
+ await expect(await elementInteractions.textContent(selector)).toMatchObject(
642
+ object,
643
+ options,
644
+ );
645
+ },
646
+ shouldStrictEqual: async (selector, expected, options) => {
647
+ options = options ?? {};
648
+
649
+ expected = await resolveVariable(expected);
650
+
651
+ await expect(
652
+ Number(await elementInteractions.textContent(selector)),
653
+ ).toStrictEqual(expected, options);
654
+ },
655
+ shouldThrow: async (fn, options) => {
656
+ options = options ?? {};
657
+
658
+ fn = await resolveVariable(fn);
659
+
660
+ await expect(fn).toThrow(options);
661
+ },
662
+ shouldAny: async (selector, constructor, options) => {
663
+ options = options ?? {};
664
+
665
+ constructor = await resolveVariable(constructor);
666
+
667
+ await expect(
668
+ await elementInteractions.textContent(selector),
669
+ ).any.toBeInstanceOf(constructor, options);
670
+ },
671
+ shouldAnything: async (selector, options) => {
672
+ options = options ?? {};
673
+
674
+ await expect(await elementInteractions.textContent(selector)).anything(
675
+ options,
676
+ );
677
+ },
678
+ shouldArrayContaining: async (selector, elements, options) => {
679
+ options = options ?? {};
680
+
681
+ elements = elements.map((element) => resolveVariable(element));
682
+
683
+ await expect(await elementInteractions.textContent(selector)).toEqual(
684
+ expect.arrayContaining(elements),
685
+ options,
686
+ );
687
+ },
688
+ shouldCloseTo: async (selector, expected, precision, options) => {
689
+ options = options ?? {};
690
+
691
+ expected = await resolveVariable(expected);
692
+ precision = await resolveVariable(precision);
693
+
694
+ await expect(
695
+ Number(await elementInteractions.textContent(selector)),
696
+ ).toBeCloseTo(expected, precision, options);
697
+ },
698
+ shouldObjectContaining: async (selector, properties, options) => {
699
+ options = options ?? {};
700
+
701
+ properties = await resolveVariable(properties);
702
+
703
+ await expect(await elementInteractions.textContent(selector)).toEqual(
704
+ expect.objectContaining(properties),
705
+ options,
706
+ );
707
+ },
708
+ shouldStringContaining: async (selector, substring, options) => {
709
+ options = options ?? {};
710
+
711
+ substring = await resolveVariable(substring);
712
+
713
+ await expect(await elementInteractions.textContent(selector)).toEqual(
714
+ expect.stringContaining(substring),
715
+ options,
716
+ );
717
+ },
718
+ shouldStringMatching: async (selector, regex, options) => {
719
+ options = options ?? {};
720
+
721
+ regex = await resolveVariable(regex);
722
+
723
+ await expect(await elementInteractions.textContent(selector)).toEqual(
724
+ expect.stringMatching(regex),
725
+ options,
726
+ );
727
+ },
728
+
729
+ // Negative Value Assertion
730
+ shouldNotBe: async (selector, expected, options) => {
731
+ options = options ?? {};
732
+
733
+ expected = await resolveVariable(expected);
734
+
735
+ await expect(await elementInteractions.textContent(selector)).not.toBe(
736
+ expected,
737
+ options,
738
+ );
739
+ },
740
+ shouldNotBeCloseTo: async (selector, expected, precision, options) => {
741
+ options = options ?? {};
742
+
743
+ expected = await resolveVariable(expected);
744
+ precision = await resolveVariable(precision);
745
+
746
+ await expect(
747
+ Number(await elementInteractions.textContent(selector)),
748
+ ).not.toBeCloseTo(expected, precision, options);
749
+ },
750
+ shouldNotBeDefined: async (selector, options) => {
751
+ options = options ?? {};
752
+
753
+ await expect(
754
+ await elementInteractions.textContent(selector),
755
+ ).not.toBeDefined(options);
756
+ },
757
+ shouldNotBeFalsy: async (selector, options) => {
758
+ options = options ?? {};
759
+
760
+ await expect(await elementInteractions.textContent(selector)).not.toBeFalsy(
761
+ options,
762
+ );
763
+ },
764
+ shouldNotBeGreaterThan: async (selector, expected, options) => {
765
+ options = options ?? {};
766
+
767
+ expected = await resolveVariable(expected);
768
+
769
+ await expect(
770
+ await elementInteractions.textContent(selector),
771
+ ).not.toBeGreaterThan(expected, options);
772
+ },
773
+ shouldNotBeGreaterThanOrEqual: async (selector, expected, options) => {
774
+ options = options ?? {};
775
+
776
+ expected = await resolveVariable(expected);
777
+
778
+ await expect(
779
+ Number(await elementInteractions.textContent(selector)),
780
+ ).not.toBeGreaterThanOrEqual(expected, options);
781
+ },
782
+ shouldNotBeInstanceOf: async (selector, constructor, options) => {
783
+ options = options ?? {};
784
+
785
+ constructor = await resolveVariable(constructor);
786
+
787
+ await expect(
788
+ await elementInteractions.textContent(selector),
789
+ ).not.toBeInstanceOf(constructor, options);
790
+ },
791
+ shouldNotBeLessThan: async (selector, expected, options) => {
792
+ options = options ?? {};
793
+
794
+ expected = await resolveVariable(expected);
795
+
796
+ await expect(
797
+ Number(await elementInteractions.textContent(selector)),
798
+ ).not.toBeLessThan(expected, options);
799
+ },
800
+ shouldNotBeLessThanOrEqual: async (selector, expected, options) => {
801
+ options = options ?? {};
802
+
803
+ expected = await resolveVariable(expected);
804
+
805
+ await expect(
806
+ Number(await elementInteractions.textContent(selector)),
807
+ ).not.toBeLessThanOrEqual(expected, options);
808
+ },
809
+ shouldNotBeNaN: async (selector, options) => {
810
+ options = options ?? {};
811
+
812
+ await expect(
813
+ Number(await elementInteractions.textContent(selector)),
814
+ ).not.toBeNaN(options);
815
+ },
816
+ shouldNotBeNull: async (selector, options) => {
817
+ options = options ?? {};
818
+
819
+ await expect(await elementInteractions.textContent(selector)).not.toBeNull(
820
+ options,
821
+ );
822
+ },
823
+ shouldNotBeTruthy: async (selector, options) => {
824
+ options = options ?? {};
825
+
826
+ await expect(
827
+ await elementInteractions.textContent(selector),
828
+ ).not.toBeTruthy(options);
829
+ },
830
+ shouldNotBeUndefined: async (selector, options) => {
831
+ options = options ?? {};
832
+
833
+ await expect(
834
+ await elementInteractions.textContent(selector),
835
+ ).not.toBeUndefined(options);
836
+ },
837
+ shouldNotContain: async (selector, substring, options) => {
838
+ options = options ?? {};
839
+
840
+ substring = await resolveVariable(substring);
841
+
842
+ await expect(await elementInteractions.textContent(selector)).not.toContain(
843
+ substring,
844
+ options,
845
+ );
846
+ },
847
+ shouldNotContainEqual: async (selector, expected, options) => {
848
+ options = options ?? {};
849
+
850
+ expected = await resolveVariable(expected);
851
+
852
+ await expect(
853
+ Number(await elementInteractions.textContent(selector)),
854
+ ).not.toContainEqual(expected, options);
855
+ },
856
+ shouldNotEqual: async (selector, expected, options) => {
857
+ options = options ?? {};
858
+
859
+ expected = await resolveVariable(expected);
860
+
861
+ await expect(
862
+ Number(await elementInteractions.textContent(selector)),
863
+ ).not.toEqual(expected, options);
864
+ },
865
+ shouldNotHaveLength: async (selector, length, options) => {
866
+ options = options ?? {};
867
+
868
+ length = await resolveVariable(length);
869
+
870
+ await expect(
871
+ await elementInteractions.textContent(selector),
872
+ ).not.toHaveLength(length, options);
873
+ },
874
+ shouldNotHaveProperty: async (selector, property, options) => {
875
+ options = options ?? {};
876
+
877
+ property = await resolveVariable(property);
878
+
879
+ await expect(
880
+ await elementInteractions.textContent(selector),
881
+ ).not.toHaveProperty(property, options);
882
+ },
883
+ shouldNotMatch: async (selector, regex, options) => {
884
+ options = options ?? {};
885
+
886
+ regex = await resolveVariable(regex);
887
+
888
+ await expect(await elementInteractions.textContent(selector)).not.toMatch(
889
+ regex,
890
+ options,
891
+ );
892
+ },
893
+ shouldNotMatchObject: async (selector, object, options) => {
894
+ options = options ?? {};
895
+
896
+ object = await resolveVariable(object);
897
+
898
+ await expect(
899
+ await elementInteractions.textContent(selector),
900
+ ).not.toMatchObject(object, options);
901
+ },
902
+ shouldNotStrictEqual: async (selector, expected, options) => {
903
+ options = options ?? {};
904
+
905
+ expected = await resolveVariable(expected);
906
+
907
+ await expect(
908
+ Number(await elementInteractions.textContent(selector)),
909
+ ).not.toStrictEqual(expected, options);
910
+ },
911
+ shouldNotThrow: async (fn, options) => {
912
+ options = options ?? {};
913
+
914
+ fn = await resolveVariable(fn);
915
+
916
+ await expect(fn).not.toThrow(options);
917
+ },
918
+ shouldNotAny: async (selector, constructor, options) => {
919
+ options = options ?? {};
920
+
921
+ constructor = await await resolveVariable(constructor);
922
+
923
+ await expect(
924
+ await elementInteractions.textContent(selector),
925
+ ).any.toBeInstanceOf(constructor, options);
926
+ },
927
+ shouldNotAnything: async (selector, options) => {
928
+ options = options ?? {};
929
+
930
+ await expect(await elementInteractions.textContent(selector)).not.anything(
931
+ options,
932
+ );
933
+ },
934
+ shouldNotArrayContaining: async (selector, elements, options) => {
935
+ options = options ?? {};
936
+
937
+ elements = elements.map((element) => resolveVariable(element));
938
+
939
+ await expect(await elementInteractions.textContent(selector)).not.toEqual(
940
+ expect.arrayContaining(elements),
941
+ options,
942
+ );
943
+ },
944
+ shouldNotCloseTo: async (selector, expected, precision, options) => {
945
+ options = options ?? {};
946
+
947
+ expected = await resolveVariable(expected);
948
+ precision = await resolveVariable(precision);
949
+
950
+ await expect(
951
+ Number(await elementInteractions.textContent(selector)),
952
+ ).not.toBeCloseTo(expected, precision, options);
953
+ },
954
+ shouldNotObjectContaining: async (selector, properties, options) => {
955
+ options = options ?? {};
956
+
957
+ properties = await resolveVariable(properties);
958
+
959
+ await expect(await elementInteractions.textContent(selector)).not.toEqual(
960
+ expect.objectContaining(properties),
961
+ options,
962
+ );
963
+ },
964
+ shouldNotStringContaining: async (selector, substring, options) => {
965
+ options = options ?? {};
966
+
967
+ substring = await resolveVariable(substring);
968
+
969
+ await expect(await elementInteractions.textContent(selector)).not.toEqual(
970
+ expect.stringContaining(substring),
971
+ options,
972
+ );
973
+ },
974
+ shouldNotStringMatching: async (selector, regex, options) => {
975
+ options = options ?? {};
976
+
977
+ regex = await resolveVariable(regex);
978
+
979
+ await expect(await elementInteractions.textContent(selector)).not.toEqual(
980
+ expect.stringMatching(regex),
981
+ options,
982
+ );
983
+ },
984
+ };
985
+
986
+ module.exports = { assert };