1
votes

I want to connect Cypress and Cucumber and I found the following plugin: https://www.npmjs.com/package/cypress-cucumber-preprocessor

But my implementation does not work and cannot be found. I also added the plugin into the plugins/index.js folder.

cypess/integration/test.feature

Feature: Background Section

   Background:
    Given counter has been reset

   Scenario: Basic example #1
     When counter is incremented
     Then counter equals 1

   Scenario: Basic example #2
     When counter is incremented
     When counter is incremented
     Then counter equals 2

cypess/integration/test.js

let counter = 0;

Given("counter has been reset", () => {
  counter = 0;
});

When("counter is incremented", () => {
  counter += 1;
});

Then("counter equals {int}", value => {
  expect(counter).to.equal(value);
});

cypess/plugins/index.js

// Cucumber Plugin
const cucumber = require('cypress-cucumber-preprocessor').default
module.exports = (on, config) => {
  on('file:preprocessor', cucumber())
}

Error

enter image description here

1
Made it work myself. See jogelin answer at https://github.com/TheBrainFamily/cypress-cucumber-preprocessor/issues/126 - laprof

1 Answers

-1
votes

You must to configure path to step_definitions, if you want to customize it.

But if you prefer the easy way, by default cypress-cucumber-preprocessor uses the folder cypress/support/step_definitions

So I believe that if you move your test.js file to the folder described above, will solve your problem.