|
| 1 | +Feature: step hooks |
| 2 | + |
| 3 | + Background: |
| 4 | + Given additional preprocessor configuration |
| 5 | + """ |
| 6 | + { |
| 7 | + "messages": { |
| 8 | + "enabled": true |
| 9 | + } |
| 10 | + } |
| 11 | + """ |
| 12 | + |
| 13 | + Rule: skipped step hooks should affect the step result |
| 14 | + |
| 15 | + Background: |
| 16 | + Given a file named "cypress/e2e/a.feature" with: |
| 17 | + """ |
| 18 | + Feature: a feature |
| 19 | + Scenario: a scenario |
| 20 | + Given a preceding step |
| 21 | + And a skipped step |
| 22 | + And a succeeding step |
| 23 | + """ |
| 24 | + And a file named "cypress/support/step_definitions/steps.js" with: |
| 25 | + """ |
| 26 | + const { Given } = require("@badeball/cypress-cucumber-preprocessor"); |
| 27 | + Given("a preceding step", function () {}) |
| 28 | + Given("a skipped step", function() {}) |
| 29 | + Given("a succeeding step", function () {}) |
| 30 | + """ |
| 31 | + |
| 32 | + Scenario: returning literal 'skipped' in BeforeStep |
| 33 | + Given a file named "cypress/support/step_definitions/hooks.js" with: |
| 34 | + """ |
| 35 | + const { BeforStep } = require("@badeball/cypress-cucumber-preprocessor"); |
| 36 | + BeforeStep(function ({ pickleStep }) { |
| 37 | + if (pickleStep.text === "a skipped step") { |
| 38 | + return "skipped"; |
| 39 | + } |
| 40 | + }); |
| 41 | + """ |
| 42 | + When I run cypress |
| 43 | + Then it passes |
| 44 | + And there should be a messages similar to "fixtures/skipped-steps.ndjson" |
| 45 | + |
| 46 | + Scenario: returning wrapped 'skipped' in BeforeStep |
| 47 | + Given a file named "cypress/support/step_definitions/hooks.js" with: |
| 48 | + """ |
| 49 | + const { BeforStep } = require("@badeball/cypress-cucumber-preprocessor"); |
| 50 | + BeforeStep(function ({ pickleStep }) { |
| 51 | + if (pickleStep.text === "a skipped step") { |
| 52 | + return cy.wrap("skipped"); |
| 53 | + } |
| 54 | + }); |
| 55 | + """ |
| 56 | + When I run cypress |
| 57 | + Then it passes |
| 58 | + And there should be a messages similar to "fixtures/skipped-steps.ndjson" |
| 59 | + |
| 60 | + Scenario: returning literal 'skipped' in AferStep |
| 61 | + Given a file named "cypress/support/step_definitions/hooks.js" with: |
| 62 | + """ |
| 63 | + const { AferStep } = require("@badeball/cypress-cucumber-preprocessor"); |
| 64 | + AferStep(function ({ pickleStep }) { |
| 65 | + if (pickleStep.text === "a skipped step") { |
| 66 | + return "skipped"; |
| 67 | + } |
| 68 | + }); |
| 69 | + """ |
| 70 | + When I run cypress |
| 71 | + Then it passes |
| 72 | + And there should be a messages similar to "fixtures/skipped-steps.ndjson" |
| 73 | + |
| 74 | + Scenario: returning wrapped 'skipped' in AferStep |
| 75 | + Given a file named "cypress/support/step_definitions/hooks.js" with: |
| 76 | + """ |
| 77 | + const { BeforStep } = require("@badeball/cypress-cucumber-preprocessor"); |
| 78 | + AferStep(function ({ pickleStep }) { |
| 79 | + if (pickleStep.text === "a skipped step") { |
| 80 | + return cy.wrap("skipped"); |
| 81 | + } |
| 82 | + }); |
| 83 | + """ |
| 84 | + When I run cypress |
| 85 | + Then it passes |
| 86 | + And there should be a messages similar to "fixtures/skipped-steps.ndjson" |
| 87 | + |
| 88 | + Rule: pending step hooks should affect the step result |
| 89 | + |
| 90 | + Background: |
| 91 | + Given a file named "cypress/e2e/a.feature" with: |
| 92 | + """ |
| 93 | + Feature: a feature |
| 94 | + Scenario: a scenario |
| 95 | + Given a preceding step |
| 96 | + And a pending step |
| 97 | + And a succeeding step |
| 98 | + """ |
| 99 | + And a file named "cypress/support/step_definitions/steps.js" with: |
| 100 | + """ |
| 101 | + const { Given } = require("@badeball/cypress-cucumber-preprocessor"); |
| 102 | + Given("a preceding step", function () {}) |
| 103 | + Given("a pending step", function() {}) |
| 104 | + Given("a succeeding step", function () {}) |
| 105 | + """ |
| 106 | + |
| 107 | + Scenario: returning literal 'pending' in BeforeStep |
| 108 | + Given a file named "cypress/support/step_definitions/hooks.js" with: |
| 109 | + """ |
| 110 | + const { BeforStep } = require("@badeball/cypress-cucumber-preprocessor"); |
| 111 | + BeforeStep(function ({ pickleStep }) { |
| 112 | + if (pickleStep.text === "a pending step") { |
| 113 | + return "pending"; |
| 114 | + } |
| 115 | + }); |
| 116 | + """ |
| 117 | + When I run cypress |
| 118 | + Then it passes |
| 119 | + And there should be a messages similar to "fixtures/pending-steps.ndjson" |
| 120 | + |
| 121 | + Scenario: returning wrapped 'pending' in BeforeStep |
| 122 | + Given a file named "cypress/support/step_definitions/hooks.js" with: |
| 123 | + """ |
| 124 | + const { BeforStep } = require("@badeball/cypress-cucumber-preprocessor"); |
| 125 | + BeforeStep(function ({ pickleStep }) { |
| 126 | + if (pickleStep.text === "a pending step") { |
| 127 | + return cy.wrap("pending"); |
| 128 | + } |
| 129 | + }); |
| 130 | + """ |
| 131 | + When I run cypress |
| 132 | + Then it passes |
| 133 | + And there should be a messages similar to "fixtures/pending-steps.ndjson" |
| 134 | + |
| 135 | + Scenario: returning literal 'pending' in AferStep |
| 136 | + Given a file named "cypress/support/step_definitions/hooks.js" with: |
| 137 | + """ |
| 138 | + const { AferStep } = require("@badeball/cypress-cucumber-preprocessor"); |
| 139 | + AferStep(function ({ pickleStep }) { |
| 140 | + if (pickleStep.text === "a pending step") { |
| 141 | + return "pending"; |
| 142 | + } |
| 143 | + }); |
| 144 | + """ |
| 145 | + When I run cypress |
| 146 | + Then it passes |
| 147 | + And there should be a messages similar to "fixtures/pending-steps.ndjson" |
| 148 | + |
| 149 | + Scenario: returning wrapped 'pending' in AferStep |
| 150 | + Given a file named "cypress/support/step_definitions/hooks.js" with: |
| 151 | + """ |
| 152 | + const { BeforStep } = require("@badeball/cypress-cucumber-preprocessor"); |
| 153 | + AferStep(function ({ pickleStep }) { |
| 154 | + if (pickleStep.text === "a pending step") { |
| 155 | + return cy.wrap("pending"); |
| 156 | + } |
| 157 | + }); |
| 158 | + """ |
| 159 | + When I run cypress |
| 160 | + Then it passes |
| 161 | + And there should be a messages similar to "fixtures/pending-steps.ndjson" |
0 commit comments