Skip to content

Commit d173e64

Browse files
authored
Merge pull request #1 from cucumber/master
Merging from cucumber/cucmber
2 parents 7cfb9b3 + 9acaa3e commit d173e64

File tree

18 files changed

+572
-363
lines changed

18 files changed

+572
-363
lines changed

.eslintrc.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
extends:
22
- standard-with-typescript
33
- "plugin:prettier/recommended"
4-
- "prettier/@typescript-eslint"
54
parserOptions:
65
project: './tsconfig.json'
76
rules:

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ jobs:
1414
- ubuntu-latest
1515
- windows-latest
1616
node-version: [10.x, 12.x, 14.x, 15.x]
17+
fail-fast: false
18+
1719
steps:
1820
- uses: actions/checkout@v2
1921
- name: with Node.js ${{ matrix.node-version }} on ${{ matrix.os }}

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CO
2222
### Fixed
2323

2424
* Fix types for hook functions so they can return e.g. `'skipped'` ([#1542](https://github.com/cucumber/cucumber-js/pull/1542))
25+
* Display the response of the reports server when an error is returned before failing. ([#1608](https://github.com/cucumber/cucumber-js/pull/1608))
2526

2627
## [7.0.0] (2020-12-21)
2728

cucumber.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
const feature = [
22
'--require-module ts-node/register',
33
'--require features/**/*.ts',
4-
`--format ${
5-
process.env.CI || !process.stdout.isTTY ? 'progress' : 'progress-bar'
6-
}`,
4+
`--format progress-bar`,
75
'--format rerun:@rerun.txt',
86
'--format usage:usage.txt',
97
'--format message:messages.ndjson',

docs/cli.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ abort the run on first failure (default: false)
153153

154154
By default, cucumber-js runs the entire suite and reports all the failures. This flag allows a developer workflow where you work on one failure at a time. Combining this feature with rerun files allows you to work through all failures in an efficient manner.
155155

156+
A note on using in conjunction with `--retry`: we consider a test case to have failed if it exhausts retries and still fails, but passed if it passes on a retry having failed previous attempts, so `--fail-fast` does still allow retries to happen.
157+
156158
## Retry failing tests
157159

158160
Use `--retry <int>` to rerun tests that have been failing. This can be very helpful for flaky tests.
@@ -170,7 +172,7 @@ For instance, for ES6 support with [Babel](https://babeljs.io/) 7 add:
170172
--require-module @babel/register
171173
```
172174

173-
This will effectivally call `require('@babel/register')` prior to requiring any support files.
175+
This will effectively call `require('@babel/register')` prior to requiring any support files.
174176

175177
### Non JS files
176178

docs/nodejs_example.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
- Install Cucumber modules with [yarn](https://yarnpkg.com/en/) **or** [npm](https://www.npmjs.com/)
55

66
```
7-
yarn add -D npm install @cucumber/cucumber
7+
yarn add -D @cucumber/cucumber
88
9-
npm i -D npm install @cucumber/cucumber
9+
npm i -D @cucumber/cucumber
1010
```
1111

1212
* Add the following files

docs/support_files/timeouts.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ Given(/^a slow step$/, {timeout: 60 * 1000}, function() {
2323
});
2424
```
2525

26+
*Note that you should not call `setDefaultTimeout` from within a hook or step; it should be called globally.*
27+
2628
## Disable Timeouts
2729

2830
**DO NOT USE THIS UNLESS ABSOLUTELY NECESSARY**

features/publish.feature

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Feature: Publish reports
5454

5555
@spawn
5656
Scenario: Report is published when CUCUMBER_PUBLISH_TOKEN is set
57-
When I run cucumber-js with arguments `` and env `CUCUMBER_PUBLISH_TOKEN=keyboardcat`
57+
When I run cucumber-js with arguments `` and env `CUCUMBER_PUBLISH_TOKEN=f318d9ec-5a3d-4727-adec-bd7b69e2edd3`
5858
Then it passes
5959
And the server should receive the following message types:
6060
| meta |
@@ -69,7 +69,7 @@ Feature: Publish reports
6969
| testStepFinished |
7070
| testCaseFinished |
7171
| testRunFinished |
72-
And the server should receive an "Authorization" header with value "Bearer keyboardcat"
72+
And the server should receive an "Authorization" header with value "Bearer f318d9ec-5a3d-4727-adec-bd7b69e2edd3"
7373

7474
@spawn
7575
Scenario: a banner is displayed after publication
@@ -101,6 +101,20 @@ Feature: Publish reports
101101
│ module.exports = { default: '--publish-quiet' } │
102102
└──────────────────────────────────────────────────────────────────────────┘
103103
"""
104+
105+
@spawn
106+
Scenario: when results are not published due to an error raised by the server, the banner is displayed
107+
When I run cucumber-js with env `CUCUMBER_PUBLISH_TOKEN=keyboardcat`
108+
Then it fails
109+
And the error output contains the text:
110+
"""
111+
┌─────────────────────┐
112+
│ Error invalid token │
113+
└─────────────────────┘
114+
115+
Unexpected http status 401 from GET http://localhost:9987
116+
"""
117+
104118
@spawn
105119
Scenario: the publication banner is not shown when publication is done
106120
When I run cucumber-js with arguments `<args>` and env `<env>`
@@ -110,10 +124,10 @@ Feature: Publish reports
110124
"""
111125

112126
Examples:
113-
| args | env |
114-
| --publish | |
115-
| | CUCUMBER_PUBLISH_ENABLED=true |
116-
| | CUCUMBER_PUBLISH_TOKEN=123456 |
127+
| args | env |
128+
| --publish | |
129+
| | CUCUMBER_PUBLISH_ENABLED=true |
130+
| | CUCUMBER_PUBLISH_TOKEN=f318d9ec-5a3d-4727-adec-bd7b69e2edd3 |
117131

118132
@spawn
119133
Scenario: the publication banner is not shown when publication is disabled

features/retry.feature

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,3 +534,60 @@ Feature: Retry flaky tests
534534
"""
535535
When I run cucumber-js with `--retry 1`
536536
Then it passes
537+
538+
Rule: using retry in combination with fail-fast will exhaust retries before failing test run
539+
540+
Scenario: a flaky scenario that passes on the second attempt, set to fail fast
541+
Given a file named "features/a.feature" with:
542+
"""
543+
Feature:
544+
Scenario: Flaky
545+
Given a flaky step
546+
547+
Scenario: Passing
548+
Given a passing step
549+
"""
550+
Given a file named "features/step_definitions/cucumber_steps.js" with:
551+
"""
552+
const {Given} = require('@cucumber/cucumber')
553+
554+
let willPass = false
555+
556+
Given(/^a flaky step$/, function() {
557+
if (willPass) {
558+
return
559+
}
560+
willPass = true
561+
throw 'fail'
562+
})
563+
564+
Given(/^a passing step$/, function() {})
565+
"""
566+
When I run cucumber-js with `--retry 1 --fail-fast`
567+
Then it passes
568+
And scenario "Flaky" attempt 0 step "Given a flaky step" has status "failed"
569+
And scenario "Flaky" attempt 1 step "Given a flaky step" has status "passed"
570+
And scenario "Passing" step "Given a passing step" has status "passed"
571+
572+
Scenario: a scenario that fails every allotted attempt, set to fail fast
573+
Given a file named "features/a.feature" with:
574+
"""
575+
Feature:
576+
Scenario: Failing
577+
Given a failing step
578+
579+
Scenario: Passing
580+
Given a passing step
581+
"""
582+
Given a file named "features/step_definitions/cucumber_steps.js" with:
583+
"""
584+
const {Given} = require('@cucumber/cucumber')
585+
586+
Given(/^a failing step$/, function() { throw 'fail' })
587+
Given(/^a passing step$/, function() {})
588+
"""
589+
When I run cucumber-js with `--retry 1 --fail-fast`
590+
Then it fails
591+
And scenario "Failing" attempt 0 step "Given a failing step" has status "failed"
592+
And scenario "Failing" attempt 1 step "Given a failing step" has status "failed"
593+
And scenario "Passing" step "Given a passing step" has status "skipped"

features/step_definitions/cli_steps.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ When(
3737
}
3838
)
3939

40+
When(
41+
/^I run cucumber-js with env `(|.+)`$/,
42+
{ timeout: 10000 },
43+
async function (this: World, envString: string) {
44+
const env = this.parseEnvString(envString)
45+
return await this.run(this.localExecutablePath, [], env)
46+
}
47+
)
48+
4049
When(
4150
/^I run cucumber-js with all formatters(?: and `(|.+)`)?$/,
4251
{ timeout: 10000 },
@@ -67,10 +76,14 @@ When(
6776
Then(/^it passes$/, () => {}) // eslint-disable-line @typescript-eslint/no-empty-function
6877

6978
Then(/^it fails$/, function (this: World) {
70-
const actualCode = doesHaveValue(this.lastRun.error)
79+
const actualCode: number = doesHaveValue(this.lastRun.error)
7180
? this.lastRun.error.code
7281
: 0
73-
expect(actualCode).not.to.eql(0)
82+
83+
expect(actualCode).not.to.eql(
84+
0,
85+
`Expected non-zero exit status, but got ${actualCode}`
86+
)
7487
this.verifiedLastRunError = true
7588
})
7689

0 commit comments

Comments
 (0)