MCPcopy
hub / github.com/cucumber/cucumber-js

github.com/cucumber/cucumber-js @v13.0.0 sqlite

repository ↗ · DeepWiki ↗ · release v13.0.0 ↗
675 symbols 1,856 edges 283 files 3 documented · 0%
README

Cucumber

Automated tests in plain language, for Node.js

Latest version on npm Coverage OpenSSF Scorecard Backers Sponsors Ukraine solidarity

Build status Release status

Cucumber is a tool for running automated tests written in plain language. Because they're written in plain language, they can be read by anyone on your team. Because they can be read by anyone, you can use them to help improve communication, collaboration and trust on your team.

This is the JavaScript implementation of Cucumber. It runs on maintained versions of Node.js. You can quickly try it via CodeSandbox, or read on to get started locally in a couple of minutes.

Looking to contribute? Read our code of conduct first, then check the contributing guide to get up and running.

Install

Cucumber is available on npm:

npm install @cucumber/cucumber

Get Started

Let's take this example of something to test:

First, write your main code in src/index.js:

class Greeter {
  sayHello() {
    return 'hello'
  }
}

module.exports = {
  Greeter
}

Then, write your feature in features/greeting.feature:

Feature: Greeting

  Scenario: Say hello
    When the greeter says hello
    Then I should have heard "hello"

Next, implement your steps in features/support/steps.js:

const assert = require('assert')
const { When, Then } = require('@cucumber/cucumber')
const { Greeter } = require('../../src')

When('the greeter says hello', function () {
  this.whatIHeard = new Greeter().sayHello()
})

Then('I should have heard {string}', function (expectedResponse) {
  assert.equal(this.whatIHeard, expectedResponse)
})

Finally, run Cucumber:

npx cucumber-js

And see the output:

Terminal output showing a successful test run with 1 scenario and 2 steps, all passing

If you learn best by example, we have a repo with several example projects, that might help you get going.

Documentation

The following documentation is for main, which might contain some unreleased features. See documentation for older versions if you need it.

Support

Support is available from the community if you need it.

Extension points exported contracts — how you extend this code

RuntimeAdapter (Interface)
(no doc) [4 implementers]
src/runtime/types.ts
IDefinition (Interface)
(no doc) [3 implementers]
src/models/definition.ts
ILogger (Interface)
(no doc) [2 implementers]
src/environment/types.ts
ISnippetSnytax (Interface)
(no doc) [1 implementers]
src/formatter/step_definition_snippet_builder/snippet_syntax.ts
CustomParameters (Interface)
(no doc)
test-d/world.ts
ILastRun (Interface)
(no doc)
features/support/world.ts
IParsedSource (Interface)
(no doc)
test/gherkin_helpers.ts
ITestSource (Interface)
(no doc)
test/formatter_helpers.ts

Core symbols most depended-on inside this repo

doesHaveValue
called by 96
src/value_checker.ts
parse
called by 45
test/gherkin_helpers.ts
testFormatter
called by 38
test/formatter_helpers.ts
finalize
called by 36
src/support_code_library_builder/index.ts
buildSupportCodeLibrary
called by 35
test/runtime_helpers.ts
reset
called by 33
src/support_code_library_builder/index.ts
emit
called by 29
src/plugin/plugin_manager.ts
matches
called by 28
src/pickle_filter.ts

Shape

Function 266
Method 186
Interface 130
Class 91
Enum 2

Languages

TypeScript100%

Modules by API surface

src/formatter/json_formatter.ts25 symbols
src/support_code_library_builder/index.ts21 symbols
src/runtime/test_case_runner.ts20 symbols
src/pickle_filter.ts19 symbols
src/plugin/plugin_manager.ts16 symbols
src/api/types.ts15 symbols
src/formatter/helpers/event_data_collector.ts14 symbols
src/runtime/attachment_manager/index.ts13 symbols
features/support/message_helpers.ts13 symbols
src/runtime/scope/make_proxy.ts12 symbols
src/runtime/parallel/adapter.ts12 symbols
src/support_code_library_builder/types.ts11 symbols

Dependencies from manifests, versioned

@biomejs/biome2.4.16 · 1×
@cucumber/biome-configgithub:cucumber/biom · 1×
@cucumber/ci-environment13.0.0 · 1×
@cucumber/compatibility-kit29.0.0 · 1×
@cucumber/cucumber-expressions19.0.1 · 1×
@cucumber/gherkin39.1.0 · 1×
@cucumber/gherkin-streams6.0.0 · 1×
@cucumber/gherkin-utils11.0.0 · 1×
@cucumber/html-formatter23.1.0 · 1×
@cucumber/junit-xml-formatter0.13.3 · 1×
@cucumber/message-streams4.1.1 · 1×
@cucumber/messages32.3.1 · 1×

For agents

$ claude mcp add cucumber-js \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact