API Test Script
first intall nodeJs
then
npm install @cucumber/cucumber
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
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.