Skip to content

Commit

Permalink
Allow outputting *only* messages
Browse files Browse the repository at this point in the history
This fixes #724.
  • Loading branch information
badeball committed Jun 15, 2022
1 parent 11c3a98 commit c49dcd1
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
27 changes: 27 additions & 0 deletions features/issues/724.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# https://github.com/badeball/cypress-cucumber-preprocessor/issues/724

Feature: outputting merely messages
Scenario: enabling *only* messages
Given additional preprocessor configuration
"""
{
"messages": {
"enabled": true
}
}
"""
And a file named "cypress/integration/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 no JSON output
But there should be a messages report
9 changes: 8 additions & 1 deletion features/step_definitions/json_steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,16 @@ Given("I've ensured cucumber-json-formatter is installed", async () => {
});
});

Then("there should be a messages report", async function () {
await assert.doesNotReject(
() => fs.access(path.join(this.tmpDir, "cucumber-messages.ndjson")),
"Expected there to be a messages file"
);
});

Then("there should be no JSON output", async function () {
await assert.rejects(
() => fs.readFile(path.join(this.tmpDir, "cucumber-messages.ndjson")),
() => fs.readFile(path.join(this.tmpDir, "cucumber-report.json")),
{
code: "ENOENT",
},
Expand Down
2 changes: 1 addition & 1 deletion lib/add-cucumber-preprocessor-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export async function beforeRunHandler(config: Cypress.PluginConfigOptions) {
export async function afterRunHandler(config: Cypress.PluginConfigOptions) {
const preprocessor = await resolve(config.projectRoot, config.env);

if (!preprocessor.messages.enabled) {
if (!preprocessor.json.enabled) {
return;
}

Expand Down

0 comments on commit c49dcd1

Please sign in to comment.