Skip to content

Commit 277f130

Browse files
Merge remote-tracking branch 'origin/main' into renovate/major-eslint-packages
2 parents e2a0a60 + 50710b6 commit 277f130

39 files changed

+2048
-1868
lines changed

.github/workflows/build.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ jobs:
3737
- uses: coverallsapp/github-action@master
3838
with:
3939
github-token: ${{ secrets.GITHUB_TOKEN }}
40+
- uses: actions/upload-artifact@v2
41+
with:
42+
name: reports
43+
path: reports
4044

4145
audit-dependencies:
4246
runs-on: ubuntu-latest

.gitignore

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
.nyc_output/
55
@rerun.txt
66
coverage/
7-
html-formatter.html
87
lib/
9-
messages.ndjson
108
node_modules
119
tmp/
12-
usage.txt
10+
reports/*.html
11+
reports/*.ndjson
12+
reports/*.txt
1313
yarn-error.log
1414
.vscode
1515
.DS_Store
16+
src/version.ts

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,23 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
88
Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CONTRIBUTING.md) on how to contribute to Cucumber.
99

1010
## [Unreleased]
11+
### Changed
12+
- Switched to new `@cucumber/ci-environment` library for CI detection ([#1868](https://github.com/cucumber/cucumber-js/pull/1868))
13+
1114
### Fixed
15+
- Handles spaces in paths for developers working on cucumbers's own code ([#1845](https://github.com/cucumber/cucumber-js/issues/1845))
16+
- Ensure package.json can be imported by consuming projects
17+
([PR#1870](https://github.com/cucumber/cucumber-js/pull/1870)
18+
[Issue#1869](https://github.com/cucumber/cucumber-js/issues/1869))
1219
- Allows for parentheses in paths for developers working on cucumber's own code ([[#1735](https://github.com/cucumber/cucumber-js/issues/1735)])
1320
- Smoother onboarding for Windows developers ([#1863](https://github.com/cucumber/cucumber-js/pull/1863))
1421

22+
### Added
23+
- Export cucumber version number. It is now possible to retrieve the current version
24+
of cucumber using `import { version } from '@cucumber/cucumber'`.
25+
([PR#1866](https://github.com/cucumber/cucumber-js/pull/1866)
26+
[Issue#1853](https://github.com/cucumber/cucumber-js/issues/1853))
27+
1528
## [8.0.0-rc.1] - 2021-10-19
1629
### Added
1730
- Add `wrapPromiseWithTimeout` to public API ([#1566](https://github.com/cucumber/cucumber-js/pull/1566))

CONTRIBUTING.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ You can chat with us in the [#committers-js](https://cucumberbdd.slack.com/archi
1111

1212
## Local setup
1313

14-
To get a local development environment, use [Git] to [fork and clone] the repo, then:
14+
To get a local development environment:
1515

16-
* If you're running Windows, make sure to enable [Developer Mode].
16+
* use [Git] to [fork and clone] the repo
17+
* If you're running Windows, make sure to enable [Developer Mode]
1718
* install [Node.Js](https://nodejs.org/en/)
19+
* Make sure you have a recent version of `npm` installed: `npm install -g npm`
1820
* `npm install` - Install dependencies
1921
* `npm test` - Compile typescript and run the tests
2022

compatibility/cck_spec.ts

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import glob from 'glob'
55
import fs from 'fs'
66
import path from 'path'
77
import { PassThrough, pipeline, Writable } from 'stream'
8-
import { Cli } from '../src'
98
import toString from 'stream-to-string'
109
import {
1110
ignorableKeys,
@@ -14,6 +13,8 @@ import {
1413
import * as messages from '@cucumber/messages'
1514
import * as messageStreams from '@cucumber/message-streams'
1615
import util from 'util'
16+
import { runCucumber } from '../src/run'
17+
import { IRunConfiguration } from '../src/configuration'
1718

1819
const asyncPipeline = util.promisify(pipeline)
1920
const PROJECT_PATH = path.join(__dirname, '..')
@@ -29,27 +30,28 @@ describe('Cucumber Compatibility Kit', () => {
2930
const suiteName = match[1]
3031
const extension = match[2]
3132
it(`passes the cck suite for '${suiteName}'`, async () => {
32-
const cliOptions = [
33-
`${CCK_FEATURES_PATH}/${suiteName}/${suiteName}${extension}`,
34-
'--require',
35-
`${CCK_IMPLEMENTATIONS_PATH}/${suiteName}/${suiteName}.ts`,
36-
'--profile',
37-
'cck',
38-
]
39-
if (suiteName === 'retry') {
40-
cliOptions.push('--retry', '2')
41-
}
42-
const args = [
43-
'node',
44-
path.join(PROJECT_PATH, 'bin', 'cucumber-js'),
45-
].concat(cliOptions)
4633
const stdout = new PassThrough()
34+
const runConfiguration: IRunConfiguration = {
35+
sources: {
36+
paths: [`${CCK_FEATURES_PATH}/${suiteName}/${suiteName}${extension}`],
37+
},
38+
support: {
39+
transpileWith: ['ts-node/register'],
40+
paths: [`${CCK_IMPLEMENTATIONS_PATH}/${suiteName}/${suiteName}.ts`],
41+
},
42+
formats: {
43+
stdout: 'message',
44+
},
45+
runtime: {
46+
retry: suiteName === 'retry' ? 2 : 0,
47+
},
48+
}
4749
try {
48-
await new Cli({
49-
argv: args,
50+
await runCucumber(runConfiguration, {
5051
cwd: PROJECT_PATH,
5152
stdout,
52-
}).run()
53+
env: process.env,
54+
})
5355
} catch (ignored) {
5456
console.error(ignored)
5557
}

cucumber.js

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,14 @@
1-
const feature = [
2-
'--require-module ts-node/register',
3-
'--require features/**/*.ts',
4-
`--format progress-bar`,
5-
'--format rerun:@rerun.txt',
6-
'--format usage:usage.txt',
7-
'--format message:messages.ndjson',
8-
'--format html:html-formatter.html',
9-
'--retry 2',
10-
'--retry-tag-filter @flaky',
11-
'--publish-quiet',
12-
].join(' ')
13-
14-
const cck = [
15-
'--require-module',
16-
'ts-node/register',
17-
'--format',
18-
'message',
19-
].join(' ')
20-
211
module.exports = {
22-
default: feature,
23-
cck,
2+
default: [
3+
'--require-module ts-node/register',
4+
'--require features/**/*.ts',
5+
`--format progress-bar`,
6+
'--format rerun:@rerun.txt',
7+
'--format usage:reports/usage.txt',
8+
'--format message:reports/messages.ndjson',
9+
'--format html:reports/html-formatter.html',
10+
'--retry 2',
11+
'--retry-tag-filter @flaky',
12+
'--publish-quiet',
13+
].join(' '),
2414
}

features/direct_imports.feature

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,26 @@ Feature: Core feature elements execution using direct imports
6060
Given(/^a step passes$/, function() {});
6161
"""
6262
When I run cucumber-js
63-
Then it passes
63+
Then it passes
64+
65+
Scenario: we can import the version number from package.json and from the library
66+
Given a file named "features/a.feature" with:
67+
"""
68+
Feature: some feature
69+
Scenario: some scenario
70+
Given a step checks the version number
71+
"""
72+
And a file named "features/step_definitions/cucumber_steps.js" with:
73+
"""
74+
const {Given} = require('@cucumber/cucumber')
75+
const package_version = require('@cucumber/cucumber/package.json').version
76+
const library_version = require('@cucumber/cucumber').version
77+
78+
Given(/^a step checks the version number$/, function() {
79+
if (package_version !== library_version) {
80+
throw new Error(`package version: ${package_version} !== library version: ${library_version}`)
81+
}
82+
});
83+
"""
84+
When I run cucumber-js
85+
Then it passes

features/formatter_paths.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Feature: Formatter Paths
2525

2626
Scenario: Absolute path
2727
Given "{{{tmpDir}}}" is an absolute path
28-
When I run cucumber-js with `-f summary:{{{tmpDir}}}/summary.txt`
28+
When I run cucumber-js with `-f summary:"{{{tmpDir}}}/summary.txt"`
2929
Then the file "{{{tmpDir}}}/summary.txt" has the text:
3030
"""
3131
1 scenario (1 passed)

features/i18n.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@spawn
12
Feature: internationalization
23

34
Scenario: view available languages

features/step_definitions/cli_steps.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,18 @@ import {
99
valueOrDefault,
1010
} from '../../src/value_checker'
1111
import { World } from '../support/world'
12-
13-
const { version } = require('../../package.json') // eslint-disable-line @typescript-eslint/no-var-requires
12+
import { version } from '../../src/version'
1413

1514
When('my env includes {string}', function (this: World, envString: string) {
1615
this.sharedEnv = this.parseEnvString(envString)
1716
})
1817

18+
When('I run cucumber-js', { timeout: 10000 }, async function (this: World) {
19+
return await this.run(this.localExecutablePath, [])
20+
})
21+
1922
When(
20-
/^I run cucumber-js(?: with `(|.+)`)?$/,
23+
'I run cucumber-js with `{}`',
2124
{ timeout: 10000 },
2225
async function (this: World, args: string) {
2326
const renderedArgs = Mustache.render(valueOrDefault(args, ''), this)
@@ -27,7 +30,7 @@ When(
2730
)
2831

2932
When(
30-
/^I run cucumber-js with arguments `(|.+)` and env `(|.+)`$/,
33+
'I run cucumber-js with arguments `{}` and env `{}`',
3134
{ timeout: 10000 },
3235
async function (this: World, args: string, envString: string) {
3336
const renderedArgs = Mustache.render(valueOrDefault(args, ''), this)
@@ -38,7 +41,7 @@ When(
3841
)
3942

4043
When(
41-
/^I run cucumber-js with env `(|.+)`$/,
44+
'I run cucumber-js with env `{}`',
4245
{ timeout: 10000 },
4346
async function (this: World, envString: string) {
4447
const env = this.parseEnvString(envString)
@@ -47,7 +50,18 @@ When(
4750
)
4851

4952
When(
50-
/^I run cucumber-js with all formatters(?: and `(|.+)`)?$/,
53+
'I run cucumber-js with all formatters',
54+
{ timeout: 10000 },
55+
async function (this: World) {
56+
const args = '--format html:html.out --format json:json.out'
57+
const renderedArgs = Mustache.render(args, this)
58+
const stringArgs = stringArgv(renderedArgs)
59+
return await this.run(this.localExecutablePath, stringArgs)
60+
}
61+
)
62+
63+
When(
64+
'I run cucumber-js with all formatters and `{}`',
5165
{ timeout: 10000 },
5266
async function (this: World, args: string) {
5367
if (doesNotHaveValue(args)) {

features/support/world.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export class World {
8383
argv: args,
8484
cwd,
8585
stdout,
86+
env,
8687
})
8788
let error: any, stderr: string
8889
try {

0 commit comments

Comments
 (0)