模块“@badeball/cypress-cucumber-preprocessor”没有导出成员“And” - TS2305

Tar*_*mić 3 testing cucumber cypress cypress-cucumber-preprocessor

我正在尝试从中导入“And”关键字,@badeball/cypress-cucumber-preprocessor以便我可以在 Cypress/Cucumber 中使用它,但出现此错误

模块“@badeball/cypress-cucumber-preprocessor”没有导出成员“And” - ts(2305)

我不知道为什么。

其他关键字如“Given”、“When”和“Then”都可以正常导入。

小智 6

您不需要And在步骤定义中使用关键字。

对于这个功能

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
Run Code Online (Sandbox Code Playgroud)

根据需要使用 When 或 Given 或 Then 来匹配And

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
});
Run Code Online (Sandbox Code Playgroud)