Home > Blockchain >  Module '"@badeball/cypress-cucumber-preprocessor"' has no exported member '
Module '"@badeball/cypress-cucumber-preprocessor"' has no exported member '

Time:10-28

I am trying to import "And" keyword from @badeball/cypress-cucumber-preprocessor so I can use it in Cypress/Cucumber, but I get this error

Module "@badeball/cypress-cucumber-preprocessor" has no exported member 'And' - ts(2305)

and I have no idea why.

Other keywords like "Given", "When" and "Then" are imported just fine.

CodePudding user response:

From version 13.0.0 onwards the support for AND and BUT is removed.

https://github.com/badeball/cypress-cucumber-preprocessor/issues/821

See Release Notes for v13.0.0 https://github.com/badeball/cypress-cucumber-preprocessor/releases

CodePudding user response:

You don't need the And keyword in step definitions.

For this feature

Feature: duckduckgo.com
  Scenario: visiting the frontpage
    When I visit duckduckgo.com
    And I have another condition
    Then I should see a search bar
    And I have another assertion

use When or Given or Then to match the And as appropriate.

import { When, Then } from "@badeball/cypress-cucumber-preprocessor";

When("I visit duckduckgo.com", () => {
  cy.visit("https://www.duckduckgo.com");
});

When("I have another condition", () => {
  console.log('When - I have another condition')     // matched and logged to console
});

Then("I should see a search bar", () => {
  cy.get("input")
  .should(
    "have.attr",
    "placeholder",
    "Search the web without being tracked"
  );
});

Then("I have another assertion", () => {
  console.log('Then - I have another assertion')     // matched and logged to console
});
  • Related