|
| 1 | +Feature: JSON config |
| 2 | + |
| 3 | + Background: |
| 4 | + Given I've ensured cucumber-json-formatter is installed |
| 5 | + And a file named "assert_args_and_exec.js" with: |
| 6 | + """ |
| 7 | + const assert = require("assert/strict"); |
| 8 | + assert(process.argv[0].endsWith("node")); |
| 9 | + assert(process.argv[1].endsWith("assert_args_and_exec.js")); |
| 10 | + assert.equal(process.argv[2], "cucumber-json-formatter"); |
| 11 | + require("child_process").execSync(process.argv[2], { stdio: "inherit" }); |
| 12 | + """ |
| 13 | + |
| 14 | + Scenario: passed example with config args |
| 15 | + Given a file named "cypress/e2e/a.feature" with: |
| 16 | + """ |
| 17 | + Feature: a feature |
| 18 | + Scenario: a scenario |
| 19 | + Given a step |
| 20 | + """ |
| 21 | + And a file named "cypress/support/step_definitions/steps.js" with: |
| 22 | + """ |
| 23 | + const { Given } = require("@badeball/cypress-cucumber-preprocessor"); |
| 24 | + Given("a step", function() {}) |
| 25 | + """ |
| 26 | + And additional preprocessor configuration |
| 27 | + """ |
| 28 | + { |
| 29 | + "json": { |
| 30 | + "args": ["assert_args_and_exec.js", "cucumber-json-formatter"], |
| 31 | + "enabled": true, |
| 32 | + "formatter": "node" |
| 33 | + } |
| 34 | + } |
| 35 | + """ |
| 36 | + When I run cypress |
| 37 | + Then it passes |
| 38 | + And there should be a JSON output similar to "fixtures/passed-example.json" |
| 39 | + |
| 40 | + Scenario: passed example with jsonArgs through -e |
| 41 | + Given a file named "cypress/e2e/a.feature" with: |
| 42 | + """ |
| 43 | + Feature: a feature |
| 44 | + Scenario: a scenario |
| 45 | + Given a step |
| 46 | + """ |
| 47 | + And a file named "cypress/support/step_definitions/steps.js" with: |
| 48 | + """ |
| 49 | + const { Given } = require("@badeball/cypress-cucumber-preprocessor"); |
| 50 | + Given("a step", function() {}) |
| 51 | + """ |
| 52 | + And additional preprocessor configuration |
| 53 | + """ |
| 54 | + { |
| 55 | + "json": { |
| 56 | + "enabled": true, |
| 57 | + "formatter": "node" |
| 58 | + } |
| 59 | + } |
| 60 | + """ |
| 61 | + When I run cypress with "-e jsonArgs=[\"assert_args_and_exec.js\",\"cucumber-json-formatter\"]" |
| 62 | + Then it passes |
| 63 | + And there should be a JSON output similar to "fixtures/passed-example.json" |
| 64 | + |
0 commit comments