Skip to content

Commit

Permalink
Replace cucumber-json-formatter with native components
Browse files Browse the repository at this point in the history
This relates to #795, #827, #870, #966, #967.
  • Loading branch information
badeball committed Mar 26, 2023
1 parent b5ce7af commit 07606a8
Show file tree
Hide file tree
Showing 25 changed files with 253 additions and 163 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ All notable changes to this project will be documented in this file.

- Correctly set `willBeRetried` in messages reports, fixes [#849](https://github.com/badeball/cypress-cucumber-preprocessor/issues/849).

- Replace [cucumber-json-formatter](https://github.com/cucumber/json-formatter) with native components, relates to [#795](https://github.com/badeball/cypress-cucumber-preprocessor/issues/795), [#827](https://github.com/badeball/cypress-cucumber-preprocessor/issues/827), [#870](https://github.com/badeball/cypress-cucumber-preprocessor/issues/870), [#966](https://github.com/badeball/cypress-cucumber-preprocessor/issues/966) and [#967](https://github.com/badeball/cypress-cucumber-preprocessor/issues/967).

## v15.1.5

- Correctly escape injected values to glob patterns, fixes [#946](https://github.com/badeball/cypress-cucumber-preprocessor/issues/946).
Expand Down
14 changes: 0 additions & 14 deletions docs/json-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ JSON reports can be enabled using the `json.enabled` property. The preprocessor
}
```

This **requires** you to have downloaded and installed the [cucumber-json-formatter](https://github.com/cucumber/json-formatter) **yourself**. Arch Linux users can install it from [AUR](https://aur.archlinux.org/packages/cucumber-json-formatter).

The location of the executable is configurable through the `json.formatter` property, but it will by default search for `cucumber-json-formatter` in your `PATH`.

The report is outputted to `cucumber-report.json` in the project directory, but can be configured through the `json.output` property.

## Screenshots
Expand Down Expand Up @@ -61,13 +57,3 @@ Given("a step", function() {
attach("Zm9vYmFy", "base64:text/plain");
});
```

## Known issues

Some issues with `cucumber-json-formatter` are known and don't need to be reported again.

- Inaccurate output of `match` on undefined step definition (https://github.com/cucumber/json-formatter/issues/2)

- Inaccurate output of retried scenarios (https://github.com/cucumber/json-formatter/issues/4)

- Inaccurate output of scenario outlined with parameterized name (https://github.com/cucumber/json-formatter/issues/25)
9 changes: 6 additions & 3 deletions features/attachments.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ Feature: attachments
"""
And I've ensured cucumber-json-formatter is installed

# This test's result will likely change in the future, see
# https://github.com/cucumber/cucumber-js/issues/2260 and
# https://github.com/cucumber/cucumber-js/pull/2261
Scenario: string identity
Given a file named "cypress/e2e/a.feature" with:
"""
Expand All @@ -27,7 +30,7 @@ Feature: attachments
"""
When I run cypress
Then it passes
And there should be a JSON output similar to "fixtures/attachments/string.json"
And there should be a JSON output similar to "fixtures/attachments/string-literal.json"

Scenario: array buffer
Given a file named "cypress/e2e/a.feature" with:
Expand All @@ -45,7 +48,7 @@ Feature: attachments
"""
When I run cypress
Then it passes
And there should be a JSON output similar to "fixtures/attachments/string.json"
And there should be a JSON output similar to "fixtures/attachments/string-base64.json"

Scenario: string encoded
Given a file named "cypress/e2e/a.feature" with:
Expand All @@ -64,4 +67,4 @@ Feature: attachments
"""
When I run cypress
Then it passes
And there should be a JSON output similar to "fixtures/attachments/string.json"
And there should be a JSON output similar to "fixtures/attachments/string-base64.json"
3 changes: 3 additions & 0 deletions features/fixtures/attachments/screenshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"name": "a scenario",
"steps": [
{
"arguments": [],
"keyword": "Given ",
"line": 3,
"name": "a step",
Expand All @@ -28,13 +29,15 @@
]
}
],
"tags": [],
"type": "scenario"
}
],
"id": "a-feature",
"keyword": "Feature",
"line": 1,
"name": "a feature",
"tags": [],
"uri": "cypress/e2e/a.feature"
}
]
2 changes: 1 addition & 1 deletion features/fixtures/attachments/screenshot.ndjson
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{"stepDefinition":{"id":"id","pattern":{"source":"a step","type":"CUCUMBER_EXPRESSION"},"sourceReference":{"uri":"not available","location":{"line":0}}}}
{"testCase":{"id":"id","pickleId":"id","testSteps":[{"id":"id","pickleStepId":"id","stepDefinitionIds":["id"]}]}}
{"testCaseStarted":{"id":"id","testCaseId":"id","attempt":0,"timestamp":{"seconds":0,"nanos":0}}}
{"attachment":{"testStepId":"id","body":"iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAM0lEQVR4Aa3BAQEAAAiDMKR/51uC7QYjJDGJSUxiEpOYxCQmMYlJTGISk5jEJCYxiUnsARwEAibDACoRAAAAAElFTkSuQmCC","mediaType":"image/png","contentEncoding":"BASE64"}}
{"attachment":{"testCaseStartedId": "id", "testStepId":"id","body":"iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAM0lEQVR4Aa3BAQEAAAiDMKR/51uC7QYjJDGJSUxiEpOYxCQmMYlJTGISk5jEJCYxiUnsARwEAibDACoRAAAAAElFTkSuQmCC","mediaType":"image/png","contentEncoding":"BASE64"}}
{"testStepStarted":{"testStepId":"id","testCaseStartedId":"id","timestamp":{"seconds":0,"nanos":0}}}
{"testStepFinished":{"testStepId":"id","testCaseStartedId":"id","testStepResult":{"status":"PASSED","duration":0},"timestamp":{"seconds":0,"nanos":0}}}
{"testCaseFinished":{"testCaseStartedId":"id","timestamp":{"seconds":0,"nanos":0},"willBeRetried":false}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"name": "a scenario",
"steps": [
{
"arguments": [],
"keyword": "Given ",
"line": 3,
"name": "a step",
Expand All @@ -28,13 +29,15 @@
]
}
],
"tags": [],
"type": "scenario"
}
],
"id": "a-feature",
"keyword": "Feature",
"line": 1,
"name": "a feature",
"tags": [],
"uri": "cypress/e2e/a.feature"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,7 @@
"name": "a scenario",
"steps": [
{
"keyword": "Given ",
"line": 3,
"name": "a step",
"result": {
"status": "failed",
"error_message": "some error"
},
"match": {
"location": "not available:0"
}
}
],
"type": "scenario"
},
{
"description": "",
"id": "a-feature;a-scenario",
"keyword": "Scenario",
"line": 2,
"name": "a scenario",
"steps": [
{
"arguments": [],
"keyword": "Given ",
"line": 3,
"name": "a step",
Expand All @@ -41,16 +20,24 @@
},
"match": {
"location": "not available:0"
}
},
"embeddings": [
{
"data": "foobar",
"mime_type": "text/plain"
}
]
}
],
"tags": [],
"type": "scenario"
}
],
"id": "a-feature",
"keyword": "Feature",
"line": 1,
"name": "a feature",
"tags": [],
"uri": "cypress/e2e/a.feature"
}
]
13 changes: 7 additions & 6 deletions features/fixtures/failing-after.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"name": "a scenario",
"steps": [
{
"arguments": [],
"keyword": "Given ",
"line": 3,
"name": "a step",
Expand All @@ -20,26 +21,26 @@
"match": {
"location": "not available:0"
}
}
],
"after": [
},
{
"keyword": "After",
"hidden": true,
"result": {
"status": "failed",
"duration": 0,
"error_message": "some error"
},
"match": {
"location": "not available:0"
}
}
],
"tags": [],
"type": "scenario"
}
],
"id": "a-feature",
"keyword": "Feature",
"line": 1,
"name": "a feature",
"tags": [],
"uri": "cypress/e2e/a.feature"
}
]
18 changes: 10 additions & 8 deletions features/fixtures/failing-before.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,39 @@
"keyword": "Scenario",
"line": 2,
"name": "a scenario",
"before": [
"steps": [
{
"keyword": "Before",
"hidden": true,
"result": {
"status": "failed",
"duration": 0,
"error_message": "some error"
},
"match": {
"location": "not available:0"
}
}
],
"steps": [
},
{
"arguments": [],
"keyword": "Given ",
"line": 3,
"name": "a step",
"result": {
"status": "skipped"
"status": "skipped",
"duration": 0
},
"match": {
"location": "not available:0"
}
}
],
"tags": [],
"type": "scenario"
}
],
"id": "a-feature",
"keyword": "Feature",
"line": 1,
"name": "a feature",
"tags": [],
"uri": "cypress/e2e/a.feature"
}
]
8 changes: 7 additions & 1 deletion features/fixtures/failing-step.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,42 @@
"name": "a scenario",
"steps": [
{
"arguments": [],
"keyword": "Given ",
"line": 3,
"name": "a failing step",
"result": {
"status": "failed",
"duration": 0,
"error_message": "some error"
},
"match": {
"location": "not available:0"
}
},
{
"arguments": [],
"keyword": "And ",
"line": 4,
"name": "another step",
"result": {
"status": "skipped"
"status": "skipped",
"duration": 0
},
"match": {
"location": "not available:0"
}
}
],
"tags": [],
"type": "scenario"
}
],
"id": "a-feature",
"keyword": "Feature",
"line": 1,
"name": "a feature",
"tags": [],
"uri": "cypress/e2e/a.feature"
}
]
6 changes: 6 additions & 0 deletions features/fixtures/multiple-features.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"name": "a scenario",
"steps": [
{
"arguments": [],
"keyword": "Given ",
"line": 3,
"name": "a step",
Expand All @@ -22,13 +23,15 @@
}
}
],
"tags": [],
"type": "scenario"
}
],
"id": "a-feature",
"keyword": "Feature",
"line": 1,
"name": "a feature",
"tags": [],
"uri": "cypress/e2e/a.feature"
},
{
Expand All @@ -42,6 +45,7 @@
"name": "another scenario",
"steps": [
{
"arguments": [],
"keyword": "Given ",
"line": 3,
"name": "a step",
Expand All @@ -54,13 +58,15 @@
}
}
],
"tags": [],
"type": "scenario"
}
],
"id": "another-feature",
"keyword": "Feature",
"line": 1,
"name": "another feature",
"tags": [],
"uri": "cypress/e2e/b.feature"
}
]
37 changes: 37 additions & 0 deletions features/fixtures/parameterized-scenario-name.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[
{
"description": "",
"elements": [
{
"description": "",
"id": "a-feature;foo",
"keyword": "Scenario Outline",
"line": 7,
"name": "foo",
"steps": [
{
"arguments": [],
"keyword": "Given ",
"line": 3,
"name": "a step",
"match": {
"location": "not available:0"
},
"result": {
"status": "passed",
"duration": 0
}
}
],
"tags": [],
"type": "scenario"
}
],
"id": "a-feature",
"line": 1,
"keyword": "Feature",
"name": "a feature",
"tags": [],
"uri": "cypress/e2e/a.feature"
}
]
Loading

0 comments on commit 07606a8

Please sign in to comment.