cucumber / cucumber-js

Cucumber for JavaScript
https://cucumber.io
MIT License
5.02k stars 1.09k forks source link

Adverbs And and But not provided #2306

Closed bliu13 closed 12 months ago

bliu13 commented 12 months ago

This is what is mentioned in the official Javascript Cucumber documentation: Recall that step definitions start with a preposition or an adverb (Given, When, Then, And, But). The problem is that there are no exports for but and and.

Version of "@cucumber/cucumber": ^9.3.0, using ESM.

step.js

import { Given, And } from '@cucumber/cucumber';

Given('I need help', () => {
  console.log('Given');
});

And('maybe I get help', () => {
  console.log('And');
});

help.feature

Feature: Need help
  Scenario: Asking For Help
    Given I need help
    And maybe I get help

Error

import { Given, And } from '@cucumber/cucumber';
                ^^^
SyntaxError: The requested module '@cucumber/cucumber' does not provide an export named 'And'
davidjgoss commented 12 months ago

And and But are shorthand keywords you a use in your feature file for readability. The step itself should be defined as either Given When or Then.