Forum Discussion

Ronal45's avatar
Ronal45
New Member
9 months ago

My cucumber test are not executed

I have configure my project correctly but when I do npm run test, it seems the cucumber tests are not recognized.

1) Scenario: Successful login # features\login.feature:3
? Given I am on the login page
Undefined. Implement with the following snippet:

Given('I am on the login page', function () {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});

? When I enter valid username and password
Undefined. Implement with the following snippet:

When('I enter valid username and password', function () {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});

? And I click on the login button
Undefined. Implement with the following snippet:

When('I click on the login button', function () {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});

? Then I should be logged in
Undefined. Implement with the following snippet:

Then('I should be logged in', function () {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});


2) Scenario: Successful logout # features\login.feature:9
? Given I am logged in
Undefined. Implement with the following snippet:

Given('I am logged in', function () {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});

? When I click on the logout button
Undefined. Implement with the following snippet:

When('I click on the logout button', function () {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});

? Then I should be logged out
Undefined. Implement with the following snippet:

Then('I should be logged out', function () {
// Write code here that turns the phrase above into concrete actions
return 'pending';
});


2 scenarios (2 undefined)
7 steps (7 undefined)
0m00.000s

Here is my loginSteps.js file

const { Given, When, Then } = require('cucumber');
const { chromium } = require('playwright');
//const LoginPage = require('./pages/LoginPage');
import {loginPage} from "./pages/LoginPage"
const DashboardPage = require('./pages/DashboardPage');

let browser;
let context;
let page;
let loginPage;
let dashboardPage;

Given('I am on the login page', async () => {
  //browser = await chromium.launch();
  //context = await browser.newContext();
 // page = await context.newPage();
 const loginPage = new LoginPage(page);
  await loginPage.navigate();
});

When('I enter valid username and password', async () => {
  await loginPage.enterUsername('ronaldo45');
  await loginPage.enterPassword('@34retryrfd');
});

When('I click on the login button', async () => {
  await loginPage.clickLoginButton();
  dashboardPage = new DashboardPage(page);
});

Then('I should be logged in', async () => {
  const isDashboardDisplayed = await dashboardPage.isDashboardDisplayed();
  expect(isDashboardDisplayed).toBe(true);
});

When('I click on the logout button', async () => {
  await dashboardPage.clickLogoutButton();
});

Then('I should be logged out', async () => {
  const isLoginPageDisplayed = await loginPage.isLoginPageDisplayed();
  expect(isLoginPageDisplayed).toBe(true);
});

After(async () => {
  await browser.close();
});
 
Please how can I solve it
No RepliesBe the first to reply