artes 1.4.7 → 1.4.9

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