Skip to content

Commit a295532

Browse files
committed
Allow outputting *only* messages
This fixes #724.
1 parent 5676bc8 commit a295532

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

features/issues/724.feature

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# https://github.com/badeball/cypress-cucumber-preprocessor/issues/724
2+
3+
Feature: outputting merely messages
4+
Scenario: enabling *only* messages
5+
Given additional preprocessor configuration
6+
"""
7+
{
8+
"messages": {
9+
"enabled": true
10+
}
11+
}
12+
"""
13+
And a file named "cypress/e2e/a.feature" with:
14+
"""
15+
Feature: a feature
16+
Scenario: a scenario
17+
Given a step
18+
"""
19+
And a file named "cypress/support/step_definitions/steps.js" with:
20+
"""
21+
const { Given } = require("@badeball/cypress-cucumber-preprocessor");
22+
Given("a step", function() {})
23+
"""
24+
When I run cypress
25+
Then it passes
26+
And there should be no JSON output
27+
But there should be a messages report

features/step_definitions/json_steps.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,16 @@ Given("I've ensured cucumber-json-formatter is installed", async () => {
6060
});
6161
});
6262

63+
Then("there should be a messages report", async function () {
64+
await assert.doesNotReject(
65+
() => fs.access(path.join(this.tmpDir, "cucumber-messages.ndjson")),
66+
"Expected there to be a messages file"
67+
);
68+
});
69+
6370
Then("there should be no JSON output", async function () {
6471
await assert.rejects(
65-
() => fs.readFile(path.join(this.tmpDir, "cucumber-messages.ndjson")),
72+
() => fs.readFile(path.join(this.tmpDir, "cucumber-report.json")),
6673
{
6774
code: "ENOENT",
6875
},

lib/add-cucumber-preprocessor-plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export async function beforeRunHandler(config: Cypress.PluginConfigOptions) {
7171
export async function afterRunHandler(config: Cypress.PluginConfigOptions) {
7272
const preprocessor = await resolve(config.projectRoot, config.env);
7373

74-
if (!preprocessor.messages.enabled) {
74+
if (!preprocessor.json.enabled) {
7575
return;
7676
}
7777

0 commit comments

Comments
 (0)