New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

bdd-expressions

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bdd-expressions

Expressive syntax for BDD step definitions

latest
Source
npmnpm
Version
0.2.0
Version published
Weekly downloads
1K
386.26%
Maintainers
1
Weekly downloads
 
Created
Source

bdd-expressions

lint test npm version license

Extended syntax for BDD steps, a superset of Cucumber Expressions.

🚀 Playground | Syntax | API | Comparison

Features

  • Named parameters with type
    • I open :page{string}
    • I set rating :rating{int}
  • Named parameters without type
    • I open :page (treated as {string})
  • Anonymous parameters (same as in Cucumber)
    • I open {string}
    • I set rating {int}
  • Inline choice parameters
    • Set status {pending/approved/rejected}
  • Optional text with parameters
    • I create :item( as :owner)
  • Nested optional text
    • I create :item( as :owner( in :workspace))
  • Multi-word alternatives without escaping
    • I (click/tap on/press and hold) button
  • Alternatives with parameters
    • I choose (page :page/label :label)
  • Full support for Cucumber Expressions syntax
    • I have {int} cucumber(s) in my belly/stomach

Automatic Type Inference

The BddExpression constructor automatically infers parameter types from your expression, providing accurate TypeScript typings, autocomplete, and compile-time checks for named parameters and optional captures.

const expression = new BddExpression('I buy :count{int} apples( for :owner)', registry);
const result = await expression.matchValues('I buy 2 apples');
/*
{
  count: number;
  owner: string | undefined;
}
*/

See the API guide for details and how to supply manual types or disable inference.

Comparison with Cucumber Expressions

Comparison with the JavaScript implementation, @cucumber/cucumber-expressions@20.1.0.

CapabilityCucumber ExpressionsBDD Expressions
Named parameters❌ (#206)✅ :page, :count{int}
Anonymous typed parameters✅ {int}, {string}, 11 built-ins✅ Same built-ins
Inline choice types❌ Requires a custom type (#304)✅ {pending/approved}
Optional text with parameters❌ (#305, #166, #299)✅ ( as :owner)
Nested optional text❌✅ ( as :owner( in :workspace))
Multi-word alternatives without escaping❌ Spaces must be escaped (#41, #75)✅ (click/tap on/press and hold)
Alternatives with parameters❌ (#41)✅ (page :page/label :label)
Optional literal text✅ cucumber(s)✅ cucumber(s)
Single-word alternatives✅ belly/stomach✅ belly/stomach
Explicit optional whitespace✅ ( again)✅ ( again)
Arbitrary text✅ {}✅ {}
Custom parameter types✅✅

IDE support

The official Cucumber extension and Cucumber (Gherkin) Full Support for VS Code do not currently support the full BDD Expressions syntax for mapping feature steps to their implementations.

🛠️ Work is in progress on a dedicated VS Code extension for BDD Expressions.

Acknowledgements

Thanks to the Cucumber Expressions contributors for the syntax and architecture that inspired this package, and for the parameter types, capture handling, and test cases adapted here. See third-party notices for attribution and license details.

License

MIT.

Keywords

bdd

FAQs

Package last updated on 31 Oct 2026

Related posts