2

When I am trying to run cypress it does detect the feature files but fails to get the step definitions file and below is the error I get to see.

enter image description here

Sharing below my config:

  1. package json file snippet
{...
  "cypress-cucumber-preprocessor": {
    "nonGlobalStepDefinitions": true,
  }
}
  1. cypress.json
{
   ...
   "testFiles": "**/*.{feature,features}"
}
  1. plugins/index.js
const cucumber = require('cypress-cucumber-preprocessor').default
 
module.exports = (on, config) => {
  on('file:preprocessor', cucumber())
}

Also sharing my test files:

Feature file (google/check-title.feature)

Feature: The Google

  I want to open google page
  
  @focus
  Scenario: Opening a social network page
    Given I open Google page
    Then I see "Google" in the title

step-definition file (google/check-title/check-title.js)

import { Given, Then } from 'cypress-cucumber-preprocessor/steps';

const url = 'https://google.com';
Given('I open Google page', () => {
  cy.visit(url);
});
Then(`I see {string} in the title`, (title) => {
  cy.title().should('include', title);
});

Marit
  • 2,399
  • 18
  • 27
Varun Sukheja
  • 6,170
  • 5
  • 51
  • 93

1 Answers1

0

This might help: in package.json set the flag nonGlobalStepDefinitions to false, and define the directory tests are coming from: "stepDefinitions": "cypress/integration/"

{
  "devDependencies": {
    "cypress": "^9.1.0",
    "cypress-cucumber-preprocessor": "^4.3.0"
  },
  "cypress-cucumber-preprocessor": {
    "nonGlobalStepDefinitions": false,
    "stepDefinitions": "cypress/integration/"
  }
}