forked from Klaveness-Digital/cypress-cucumber-preprocessor
-
-
Notifications
You must be signed in to change notification settings - Fork 149
/
Copy pathmessages.feature
695 lines (642 loc) · 21.7 KB
/
messages.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
Feature: messages report
Background:
Given additional preprocessor configuration
"""
{
"messages": {
"enabled": true
}
}
"""
Rule: it should handle basic scenarioes
Background:
Given additional Cypress configuration
"""
{
"screenshotOnRunFailure": false
}
"""
Scenario: passed example
Given a file named "cypress/e2e/a.feature" with:
"""
Feature: a feature
Scenario: a scenario
Given a step
"""
And a file named "cypress/support/step_definitions/steps.js" with:
"""
const { Given } = require("@badeball/cypress-cucumber-preprocessor");
Given("a step", function() {})
"""
When I run cypress
Then it passes
And there should be a messages similar to "fixtures/passed-example.ndjson"
Scenario: passed outline
Given a file named "cypress/e2e/a.feature" with:
"""
Feature: a feature
Scenario Outline: a scenario
Given a step
Examples:
| value |
| foo |
| bar |
"""
And a file named "cypress/support/step_definitions/steps.js" with:
"""
const { Given } = require("@badeball/cypress-cucumber-preprocessor");
Given("a step", function() {})
"""
When I run cypress
Then it passes
And there should be a messages similar to "fixtures/passed-outline.ndjson"
Scenario: multiple features
Given a file named "cypress/e2e/a.feature" with:
"""
Feature: a feature
Scenario: a scenario
Given a step
"""
And a file named "cypress/e2e/b.feature" with:
"""
Feature: another feature
Scenario: another scenario
Given a step
"""
And a file named "cypress/support/step_definitions/steps.js" with:
"""
const { Given } = require("@badeball/cypress-cucumber-preprocessor");
Given("a step", function() {})
"""
When I run cypress
Then it passes
And there should be a messages similar to "fixtures/multiple-features.ndjson"
Scenario: failing step
Given a file named "cypress/e2e/a.feature" with:
"""
Feature: a feature
Scenario: a scenario
Given a preceding step
And a failing step
And a succeeding step
"""
And a file named "cypress/support/step_definitions/steps.js" with:
"""
const { Given } = require("@badeball/cypress-cucumber-preprocessor");
Given("a preceding step", function () {})
Given("a failing step", function() {
throw "some error"
})
Given("a succeeding step", function () {})
"""
When I run cypress
Then it fails
And there should be a messages similar to "fixtures/failing-step.ndjson"
Scenario: undefined step
Given a file named "cypress/e2e/a.feature" with:
"""
Feature: a feature
Scenario: a scenario
Given a preceding step
And an undefined step
And a succeeding step
"""
And a file named "cypress/support/step_definitions/steps.js" with:
"""
const { Given } = require("@badeball/cypress-cucumber-preprocessor");
Given("a preceding step", function () {})
Given("a succeeding step", function () {})
"""
When I run cypress
Then it fails
And there should be a messages similar to "fixtures/undefined-steps.ndjson"
Scenario: pending step
Given a file named "cypress/e2e/a.feature" with:
"""
Feature: a feature
Scenario: a scenario
Given a preceding step
And a pending step
And a succeeding step
"""
And a file named "cypress/support/step_definitions/steps.js" with:
"""
const { Given } = require("@badeball/cypress-cucumber-preprocessor");
Given("a preceding step", function () {})
Given("a pending step", function () {
return "pending";
});
Given("a succeeding step", function () {})
"""
When I run cypress
Then it passes
And there should be a messages similar to "fixtures/pending-steps.ndjson"
Scenario: skipped step through return value
Given a file named "cypress/e2e/a.feature" with:
"""
Feature: a feature
Scenario: a scenario
Given a preceding step
And a skipped step
And a succeeding step
"""
And a file named "cypress/support/step_definitions/steps.js" with:
"""
const { Given } = require("@badeball/cypress-cucumber-preprocessor");
Given("a preceding step", function () {})
Given("a skipped step", function () {
return "skipped";
});
Given("a succeeding step", function () {})
"""
When I run cypress
Then it passes
And there should be a messages similar to "fixtures/skipped-steps.ndjson"
Scenario: skipped step through method invocation
Given a file named "cypress/e2e/a.feature" with:
"""
Feature: a feature
Scenario: a scenario
Given a preceding step
And a skipped step
And a succeeding step
"""
And a file named "cypress/support/step_definitions/steps.js" with:
"""
const { Given } = require("@badeball/cypress-cucumber-preprocessor");
Given("a preceding step", function () {})
Given("a skipped step", function () {
this.skip();
});
Given("a succeeding step", function () {})
"""
When I run cypress
Then it passes
And there should be a messages similar to "fixtures/skipped-steps.ndjson"
Scenario: retried
Given additional Cypress configuration
"""
{
"retries": 1
}
"""
And a file named "cypress/e2e/a.feature" with:
"""
Feature: a feature
Scenario: a scenario
Given a step
"""
And a file named "cypress/support/step_definitions/steps.js" with:
"""
const { Given } = require("@badeball/cypress-cucumber-preprocessor");
let attempt = 0;
Given("a step", () => {
if (attempt++ === 0) {
throw "some error";
}
});
"""
When I run cypress
Then it passes
And there should be a messages similar to "fixtures/retried.ndjson"
# And there should be a messages similar to "fixtures/passed-example.ndjson"
Scenario: rescued error
Given a file named "cypress/e2e/a.feature" with:
"""
Feature: a feature
Scenario: a scenario
Given a failing step
And an unimplemented step
"""
And a file named "cypress/support/step_definitions/steps.js" with:
"""
const { Given } = require("@badeball/cypress-cucumber-preprocessor");
Given("a failing step", function() {
throw new Error("foobar")
})
"""
And a file named "cypress/support/e2e.js" with:
"""
Cypress.on("fail", (err) => {
if (err.message.includes("foobar")) {
return;
}
throw err;
})
"""
When I run cypress
Then it passes
And there should be a messages similar to "fixtures/rescued-error.ndjson"
Scenario: failing Before hook
Given a file named "cypress/e2e/a.feature" with:
"""
Feature: a feature
Scenario: a scenario
Given a step
"""
And a file named "cypress/support/step_definitions/steps.js" with:
"""
const { Before, Given } = require("@badeball/cypress-cucumber-preprocessor");
Before(function() {
throw "some error"
})
Given("a step", function() {})
"""
When I run cypress
Then it fails
And there should be a messages similar to "fixtures/failing-before.ndjson"
Scenario: failing After hook
Given a file named "cypress/e2e/a.feature" with:
"""
Feature: a feature
Scenario: a scenario
Given a step
"""
And a file named "cypress/support/step_definitions/steps.js" with:
"""
const { After, Given } = require("@badeball/cypress-cucumber-preprocessor");
After(function() {
throw "some error"
})
Given("a step", function() {})
"""
When I run cypress
Then it fails
And there should be a messages similar to "fixtures/failing-after.ndjson"
Rule: step hooks affects the result of the current step
Background:
Given additional Cypress configuration
"""
{
"screenshotOnRunFailure": false
}
"""
Scenario: failing BeforeStep
Given a file named "cypress/e2e/a.feature" with:
"""
Feature: a feature
Scenario: a scenario
Given a preceding step
And a failing step
And a succeeding step
"""
And a file named "cypress/support/step_definitions/steps.js" with:
"""
const { BeforeStep, Given } = require("@badeball/cypress-cucumber-preprocessor");
BeforeStep(function({ pickleStep }) {
if (pickleStep.text === "a failing step") {
throw "some error"
}
})
Given("a preceding step", function () {})
Given("a failing step", function() {})
Given("a succeeding step", function () {})
"""
When I run cypress
Then it fails
And there should be a messages similar to "fixtures/failing-step.ndjson"
Scenario: failing AfterStep
Given a file named "cypress/e2e/a.feature" with:
"""
Feature: a feature
Scenario: a scenario
Given a preceding step
And a failing step
And a succeeding step
"""
And a file named "cypress/support/step_definitions/steps.js" with:
"""
const { AfterStep, Given } = require("@badeball/cypress-cucumber-preprocessor");
AfterStep(function({ pickleStep }) {
if (pickleStep.text === "a failing step") {
throw "some error"
}
})
Given("a preceding step", function () {})
Given("a failing step", function() {})
Given("a succeeding step", function () {})
"""
When I run cypress
Then it fails
And there should be a messages similar to "fixtures/failing-step.ndjson"
Rule: it should contain screenshots captured during a test
Scenario: explicit screenshot
Given a file named "cypress/e2e/a.feature" with:
"""
Feature: a feature
Scenario: a scenario
Given a step
"""
And a file named "cypress/support/step_definitions/steps.js" with:
"""
const { Given } = require("@badeball/cypress-cucumber-preprocessor");
Given("a step", function () {
cy.visit("index.html");
cy.get("div").screenshot();
});
"""
And a file named "index.html" with:
"""
<!DOCTYPE HTML>
<style>
div {
background: red;
width: 20px;
height: 20px;
}
</style>
<div />
"""
When I run cypress
Then it passes
And there should be a messages similar to "fixtures/attachments/screenshot.ndjson"
Scenario: screenshot of failed test
Given a file named "cypress/e2e/a.feature" with:
"""
Feature: a feature
Scenario: a scenario
Given a failing step
"""
And a file named "cypress/support/step_definitions/steps.js" with:
"""
const { Given } = require("@badeball/cypress-cucumber-preprocessor");
Given("a failing step", function() {
throw "some error"
})
"""
When I run cypress
Then it fails
And the messages report should contain an image attachment for what appears to be a screenshot
Rule: it should include results of skipped (not omitted) tests
Scenario: first scenario skipped
Given a file named "cypress/e2e/a.feature" with:
"""
Feature: a feature
@skip
Scenario: first scenario
Given a step
Scenario: second scenario
Given a step
Scenario: third scenario
Given a step
"""
And a file named "cypress/support/step_definitions/steps.js" with:
"""
const { Given } = require("@badeball/cypress-cucumber-preprocessor");
Given("a step", function () {});
"""
When I run cypress
Then it passes
And there should be a messages similar to "fixtures/skipped-first-scenario.ndjson"
Scenario: middle scenario skipped
Given a file named "cypress/e2e/a.feature" with:
"""
Feature: a feature
Scenario: first scenario
Given a step
@skip
Scenario: second scenario
Given a step
Scenario: third scenario
Given a step
"""
And a file named "cypress/support/step_definitions/steps.js" with:
"""
const { Given } = require("@badeball/cypress-cucumber-preprocessor");
Given("a step", function () {});
"""
When I run cypress
Then it passes
And there should be a messages similar to "fixtures/skipped-second-scenario.ndjson"
Scenario: last scenario skipped
Given a file named "cypress/e2e/a.feature" with:
"""
Feature: a feature
Scenario: first scenario
Given a step
Scenario: second scenario
Given a step
@skip
Scenario: third scenario
Given a step
"""
And a file named "cypress/support/step_definitions/steps.js" with:
"""
const { Given } = require("@badeball/cypress-cucumber-preprocessor");
Given("a step", function () {});
"""
When I run cypress
Then it passes
And there should be a messages similar to "fixtures/skipped-third-scenario.ndjson"
Scenario: all scenario skipped
Given a file named "cypress/e2e/a.feature" with:
"""
Feature: a feature
@skip
Scenario: first scenario
Given a step
@skip
Scenario: second scenario
Given a step
@skip
Scenario: third scenario
Given a step
"""
And a file named "cypress/support/step_definitions/steps.js" with:
"""
const { Given } = require("@badeball/cypress-cucumber-preprocessor");
Given("a step", function () {});
"""
When I run cypress
Then it passes
And there should be a messages similar to "fixtures/skipped-all-scenarios.ndjson"
Rule: failing Cypress hooks outside of the plugins control should discontinue the report
Scenario: failing before hook
Given a file named "cypress/e2e/a.feature" with:
"""
Feature: a feature
Scenario: a scenario
Given a step
"""
And a file named "cypress/support/step_definitions/steps.js" with:
"""
const { Given } = require("@badeball/cypress-cucumber-preprocessor");
Given("a step", function() {})
"""
And a file named "cypress/support/e2e.js" with:
"""
before(() => {
throw "some error"
});
"""
When I run cypress
Then it fails
And the output should contain
"""
Hook failures can't be represented in any reports (messages / json / html), thus none is created for cypress/e2e/a.feature.
"""
And the messages report shouldn't contain any specs
Scenario: failing beforeEach hook
Given a file named "cypress/e2e/a.feature" with:
"""
Feature: a feature
Scenario: a scenario
Given a step
"""
And a file named "cypress/support/step_definitions/steps.js" with:
"""
const { Given } = require("@badeball/cypress-cucumber-preprocessor");
Given("a step", function() {})
"""
And a file named "cypress/support/e2e.js" with:
"""
beforeEach(() => {
throw "some error"
});
"""
When I run cypress
Then it fails
And the output should contain
"""
Hook failures can't be represented in any reports (messages / json / html), thus none is created for cypress/e2e/a.feature.
"""
And the messages report shouldn't contain any specs
Scenario: failing afterEach hook
Given a file named "cypress/e2e/a.feature" with:
"""
Feature: a feature
Scenario: a scenario
Given a step
"""
And a file named "cypress/support/step_definitions/steps.js" with:
"""
const { Given } = require("@badeball/cypress-cucumber-preprocessor");
Given("a step", function() {})
"""
And a file named "cypress/support/e2e.js" with:
"""
afterEach(() => {
throw "some error"
});
"""
When I run cypress
Then it fails
And the output should contain
"""
Hook failures can't be represented in any reports (messages / json / html), thus none is created for cypress/e2e/a.feature.
"""
And the messages report shouldn't contain any specs
Scenario: failing after hook
Given a file named "cypress/e2e/a.feature" with:
"""
Feature: a feature
Scenario: a scenario
Given a step
"""
And a file named "cypress/support/step_definitions/steps.js" with:
"""
const { Given } = require("@badeball/cypress-cucumber-preprocessor");
Given("a step", function() {})
"""
And a file named "cypress/support/e2e.js" with:
"""
after(() => {
throw "some error"
});
"""
When I run cypress
Then it fails
And the output should contain
"""
Hook failures can't be represented in any reports (messages / json / html), thus none is created for cypress/e2e/a.feature.
"""
And the messages report shouldn't contain any specs
@network
Rule: it should handle reloads gracefully in a multitude of scenarios
Background:
Given a file named "cypress/e2e/a.feature" with:
"""
Feature: a feature
@env(origin="https://duckduckgo.com/")
Scenario: a scenario
Given a step
@env(origin="https://google.com/")
Scenario: another scenario
Given another step
"""
Scenario: base case
Given a file named "cypress/support/step_definitions/steps.js" with:
"""
const { Given } = require("@badeball/cypress-cucumber-preprocessor");
Given("a step", function() {});
Given("another step", function() {});
"""
When I run cypress
Then it passes
And there should be a messages similar to "fixtures/multiple-scenarios-reloaded.ndjson"
Scenario: reloading within steps
Given a file named "cypress/support/step_definitions/steps.js" with:
"""
const { Given } = require("@badeball/cypress-cucumber-preprocessor");
Given("a step", function() {
cy.visit("https://duckduckgo.com/");
});
Given("another step", function() {
cy.visit("https://google.com/");
});
"""
When I run cypress
Then it passes
And there should be a messages similar to "fixtures/multiple-scenarios-reloaded.ndjson"
Scenario: reloading in before()
Given a file named "cypress/support/step_definitions/steps.js" with:
"""
const { Given } = require("@badeball/cypress-cucumber-preprocessor");
before(() => {
cy.visit("https://duckduckgo.com/");
});
Given("a step", function() {});
Given("another step", function() {});
"""
When I run cypress
Then it passes
And there should be a messages similar to "fixtures/multiple-scenarios-reloaded.ndjson"
Scenario: reloading in after()
Given a file named "cypress/support/step_definitions/steps.js" with:
"""
const { Given } = require("@badeball/cypress-cucumber-preprocessor");
after(() => {
cy.visit("https://duckduckgo.com/");
});
Given("a step", function() {});
Given("another step", function() {});
"""
When I run cypress
Then it passes
And there should be a messages similar to "fixtures/multiple-scenarios-reloaded.ndjson"
Scenario: reloading in beforeEach()
Given a file named "cypress/support/step_definitions/steps.js" with:
"""
const { Given } = require("@badeball/cypress-cucumber-preprocessor");
beforeEach(() => {
cy.visit(Cypress.env("origin"));
});
Given("a step", function() {});
Given("another step", function() {});
"""
When I run cypress
Then it passes
And there should be a messages similar to "fixtures/multiple-scenarios-reloaded.ndjson"
Scenario: reloading in afterEach()
Given a file named "cypress/support/step_definitions/steps.js" with:
"""
const { Given } = require("@badeball/cypress-cucumber-preprocessor");
afterEach(() => {
cy.visit(Cypress.env("origin"));
});
Given("a step", function() {});
Given("another step", function() {});
"""
When I run cypress
Then it passes
And there should be a messages similar to "fixtures/multiple-scenarios-reloaded.ndjson"