API Test Script

 

npm: @cucumber/cucumber

  1. first intall nodeJs

  2. then npm install @cucumber/cucumber

  3. then define a feature:

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

4. then implement it

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) });

5. and finally run your test with

npx cucumber-js

 

npm

@cucumber/cucumber

The official JavaScript implementation of Cucumber.. Latest version: 8.6.0, last published: 9 days ago. Start using @cucumber/cucumber in your project by running npm i @cucumber/cucumber. There are 135 other projects in the npm registry using @cucumber/cucumber.