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 0fa9777 commit 1119d24
Show file tree
Hide file tree
Showing 30 changed files with 252 additions and 266 deletions.
13 changes: 2 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,10 @@ jobs:
- name: Dependencies
env:
CYPRESS_INSTALL_BINARY: "0"
CUCUMBER_JSON_FORMATTER_URL: https://github.com/cucumber/common/releases/download/json-formatter%2Fgo%2Fv19.0.0/cucumber-json-formatter-linux-amd64
run: |
npm install --force && \
npm install --no-save cypress@${{ matrix.cypress-version }} && \
env -u CYPRESS_INSTALL_BINARY npx cypress install && \
curl -L $CUCUMBER_JSON_FORMATTER_URL > /usr/bin/cucumber-json-formatter && \
chmod +x /usr/bin/cucumber-json-formatter
env -u CYPRESS_INSTALL_BINARY npx cypress install
- name: Build
run: npm run build
- name: Test
Expand Down Expand Up @@ -75,13 +72,7 @@ jobs:
key: cypress-windows
- name: Dependencies
shell: bash
env:
CUCUMBER_JSON_FORMATTER_URL: https://github.com/cucumber/common/releases/download/json-formatter%2Fgo%2Fv19.0.0/cucumber-json-formatter-windows-amd64
run: |
npm install
curl -L $CUCUMBER_JSON_FORMATTER_URL > cucumber-json-formatter.exe
chmod +x ./cucumber-json-formatter.exe
echo $GITHUB_WORKSPACE >> $GITHUB_PATH
run: npm install
- name: Build
run: npm run build
# https://github.com/webpack/webpack/issues/12759
Expand Down
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
2 changes: 0 additions & 2 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ Every configuration option has a similar key which can be use to override it, sh
| `messages.enabled` | `messagesEnabled` | `true`, `false` |
| `messages.output` | `messagesOutput` | `cucumber-messages.ndjson` |
| `json.enabled` | `jsonEnabled` | `true`, `false` |
| `json.formatter` | `jsonFormatter` | `/usr/bin/cucumber-json-formatter` |
| `json.args ` | `jsonArgs ` | `["custom-json-formatter.js"]` |
| `json.output` | `jsonOutput` | `cucumber-report.json` |
| `html.enabled` | `htmlEnabled` | `true`, `false` |
| `html.output` | `htmlOutput` | `cucumber-report.html` |
Expand Down
5 changes: 0 additions & 5 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

* [`--env` / `tags` isn't picked up](#--env--tags-isnt-picked-up)
* [I get `fs_1.promises.rm is not a function`](#i-get-fs_1promisesrm-is-not-a-function)
* [I get `spawn cucumber-json-formatter ENOENT`](#i-get-spawn-cucumber-json-formatter-enoent)
* [Why is `cypress-tags` missing?](#why-is-cypress-tags-missing)
* [My JSON report isn't generated](#my-json-report-isnt-generated)
* [JSON reports aren't generated in open / interactive mode](#json-reports-arent-generated-in-open--interactive-mode)
Expand All @@ -18,10 +17,6 @@ This might be because you're trying to specify `-e / --env` multiple times, but

Upgrade your node version to at least [v14.14.0](https://nodejs.org/api/fs.html#fspromisesrmpath-options).

## I get `spawn cucumber-json-formatter ENOENT`

You need to install `cucumber-json-formatter` **yourself**, as per [documentation](json-report.md).

## Why is `cypress-tags` missing?

The `cypress-tags` executable has been removed and made redundant. Specs containing no matching scenarios are [automatically filtered](https://github.com/badeball/cypress-cucumber-preprocessor/blob/master/docs/tags.md#running-a-subset-of-scenarios), provided that `filterSpecs` is set to true.
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)
10 changes: 6 additions & 4 deletions features/attachments.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ 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 +29,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 +47,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 +66,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"
}
]
Loading

0 comments on commit 1119d24

Please sign in to comment.