Skip to content

Commit 2d5d66e

Browse files
committed
Initial commit
0 parents  commit 2d5d66e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+8278
-0
lines changed

β€Ž.gitattributesβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text eol=lf

β€Ž.github/workflows/site.yamlβ€Ž

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Site
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
upload-artifact:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- uses: actions/setup-node@v3
14+
with:
15+
node-version: 22.x
16+
- run: npm ci
17+
- run: npm run docs
18+
- run: |
19+
chmod -c -R +rX "_site/" | while read line; do
20+
echo "::warning title=Invalid file permissions automatically fixed::$line"
21+
done
22+
- uses: actions/upload-pages-artifact@v3
23+
24+
deploy:
25+
needs: upload-artifact
26+
permissions:
27+
pages: write
28+
id-token: write
29+
environment:
30+
name: github-pages
31+
url: ${{ steps.deployment.outputs.page_url }}
32+
runs-on: ubuntu-latest
33+
steps:
34+
- id: deployment
35+
uses: actions/deploy-pages@v4

β€Ž.github/workflows/test.yamlβ€Ž

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
test:
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
matrix:
16+
os:
17+
- ubuntu-latest
18+
node-version: [22.x, 23.x]
19+
fail-fast: false
20+
21+
steps:
22+
- uses: actions/checkout@v3
23+
- name: with Node.js ${{ matrix.node-version }} on ${{ matrix.os }}
24+
uses: actions/setup-node@v3
25+
with:
26+
node-version: ${{ matrix.node-version }}
27+
- run: npm ci
28+
- run: npm run lint
29+
- run: npm test
30+
exports:
31+
runs-on: ubuntu-latest
32+
33+
steps:
34+
- uses: actions/checkout@v3
35+
- uses: actions/setup-node@v3
36+
with:
37+
node-version: 23.x
38+
- run: npm ci
39+
- run: npm run build
40+
- run: npm run exports:check

β€Ž.gitignoreβ€Ž

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
_site
2+
lib
3+
node_modules
4+
tmp
5+
tsdoc-metadata.json

β€Ž.mocharc.jsonβ€Ž

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"exit": true,
3+
"extension": ["ts", "js"],
4+
"node-option": ["import=tsx"]
5+
}

β€Ž.prettierrc.jsonβ€Ž

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"trailingComma": "es5",
3+
"semi": false,
4+
"singleQuote": true,
5+
"printWidth": 100
6+
}

β€ŽCHANGELOG.mdβ€Ž

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](http://keepachangelog.com/)
6+
and this project adheres to [Semantic Versioning](http://semver.org/).
7+
8+
Please see [CONTRIBUTING.md](./CONTRIBUTING.md) on how to contribute to Cucumber.
9+
10+
## [Unreleased]
11+
### Added
12+
- Initial implementation

β€ŽLICENSEβ€Ž

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License
2+
3+
Copyright (c) 2025 David Goss and contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining
6+
a copy of this software and associated documentation files (the
7+
"Software"), to deal in the Software without restriction, including
8+
without limitation the rights to use, copy, modify, merge, publish,
9+
distribute, sublicense, and/or sell copies of the Software, and to
10+
permit persons to whom the Software is furnished to do so, subject to
11+
the following conditions:
12+
13+
The above copyright notice and this permission notice shall be
14+
included in all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

β€ŽREADME.mdβ€Ž

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<h1 align="center">
2+
<img alt="" width="75" src="./logo.svg"/>
3+
<br>
4+
cucumber-node
5+
</h1>
6+
<p align="center">
7+
<b>Automated tests in plain language, for the Node.js test runner</b>
8+
</p>
9+
10+
[Cucumber](https://github.com/cucumber) is a tool for running automated tests written in plain language. Because they're
11+
written in plain language, they can be read by anyone on your team. Because they can be
12+
read by anyone, you can use them to help improve communication, collaboration and trust on
13+
your team.
14+
15+
⚠️ This is a new implementation of Cucumber built around the [Node.js test runner](https://nodejs.org/api/test.html). It's still in the pre-1.0.0 phase, so APIs and behaviour might change. The stable canonical implementation of Cucumber for JavaScript continues to be [@cucumber/cucumber](https://github.com/cucumber/cucumber-js) for now. ⚠️
16+
17+
## Install
18+
19+
cucumber-node is [available on npm](https://www.npmjs.com/package/@cucumber/node):
20+
21+
```shell
22+
npm install --save-dev @cucumber/node
23+
```
24+
25+
You'll need Node.js 22 or 23.
26+
27+
## Get started
28+
29+
Say we have this small class:
30+
31+
```js
32+
export class Greeter {
33+
sayHello() {
34+
return 'hello'
35+
}
36+
}
37+
```
38+
39+
Let's write a feature file specifying how it should work, in `features/greeting.feature`:
40+
41+
```gherkin
42+
Feature: Greeting
43+
44+
Scenario: Say hello
45+
When the greeter says hello
46+
Then I should have heard "hello"
47+
```
48+
49+
Next, we need to provide automation to turn that spec into tests, in `features/support/steps.js`:
50+
51+
```js
52+
import assert from 'node:assert'
53+
import { When, Then } from '@cucumber/node'
54+
import { Greeter } from '../../lib/Greeter.js'
55+
56+
When('the greeter says hello', (t) => {
57+
t.world.whatIHeard = new Greeter().sayHello()
58+
});
59+
60+
Then('I should have heard {string}', (t, expectedResponse) => {
61+
assert.equal(t.world.whatIHeard, expectedResponse)
62+
});
63+
```
64+
65+
Finally, run `node --test` with some special arguments:
66+
67+
```shell
68+
node --import @cucumber/node/bootstrap --test-reporter=dot --test 'features/**/*.feature'
69+
```
70+
71+
## Running tests
72+
73+
Since cucumber-node augments the standard Node.js test runner, you can use many of its options in the same way you would when running tests written in JavaScript, like:
74+
75+
- πŸ”€ [`--test-concurrency`](https://nodejs.org/api/cli.html#--test-concurrency) to control the number of concurrent processes
76+
- πŸƒ [`--test-force-exit`](https://nodejs.org/api/cli.html#--test-force-exit) to forcibly exit once all tests have executed
77+
- 😷 [`--test-isolation=none`](https://nodejs.org/api/cli.html#--test-isolationmode) to have all tests run in a single process
78+
- πŸ” [`--test-name-pattern`](https://nodejs.org/api/cli.html#--test-name-pattern) to target some scenarios by name
79+
- πŸ’Ž [`--test-shard`](https://nodejs.org/api/cli.html#--test-shard) to shard execution across multiple runs/environments
80+
- ⏩ [`--test-skip-pattern`](https://nodejs.org/api/cli.html#--test-skip-pattern) to omit some scenarios by name
81+
- πŸ‘€ [`--watch`](https://nodejs.org/api/cli.html#--watch) to watch for changes and automatically re-run
82+
83+
(In all cases you still need the `--import @cucumber/node/bootstrap` so that cucumber-node kicks in when a feature file is encountered.)
84+
85+
## Writing steps
86+
87+
Full API documentation is at https://cucumber.github.io/cucumber-node/ and includes:
88+
89+
- `Before` and `After` for hooks
90+
- `Given`, `When` and `Then` for steps
91+
- `ParameterType` for custom parameter types
92+
93+
## Reporters
94+
95+
Some Cucumber formatters are included as Node.js test reporters:
96+
97+
- HTML - `--test-reporter=@cucumber/node/reporters/html --test-reporter-destinaton=./report.html`
98+
- Message - `--test-reporter=@cucumber/node/reporters/message --test-reporter-destinaton=./messages.ndjson`

β€ŽRELEASING.mdβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
See [.github/RELEASING](https://github.com/cucumber/.github/blob/main/RELEASING.md).

0 commit comments

Comments
Β (0)