I recently started using the jest-cucumber library to execute my jest tests in BDD format.
However, when I try running a sample test, I encounter the following issue:
? Given Test for given step
Undefined. Implement with the following snippet:
Given('Test for given step', function () {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});
? When Test for when step
Undefined. Implement with the following snippet:
When('Test for when step', function () {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});
? Then Test for then step
Undefined. Implement with the following snippet:
Then('Test for then step', function () {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});
1 scenario (1 undefined)
3 steps (3 undefined)
0m00.000s
Process finished with exit code 1
Here is where you can locate the files:
https://i.sstatic.net/evXtK.png
Outlined below are my BDD scenarios:
Feature: E2E Tests
Scenario:Example
Given Test for given step
When Test for when step
Then Test for then step
This is how my Step definition code looks like:
import { loadFeature, defineFeature } from 'jest-cucumber';
const feature = loadFeature('/src/smokeTests/smokeTests.feature');
defineFeature(feature, (test) => {
test('Example', ({ given, when, then }) => {
let x: number;
let z: number;
given('Test for given step', () => {
x = 1;
});
when('Test for when step', () => {
z = x + 3;
});
then('Test for then step', () => {
expect(z).toBe(4);
});
});
});
Feeling a bit stuck on what my next move should be!