Cypress.io 和 Cucumber.io 测试集成,缺少步骤实现:步骤、测试、Cypress、io

2023-09-07 23:49:24 作者:许多愁

Cypress 和 Cucumber 的集成似乎进展顺利,但是执行测试时出现以下错误:

Integration of Cypress and Cucumber seem to go well, however when tests are executed I get the following error:

Step implementation missing for: I open login page

cypress.json

{
  "video": false,
  "baseUrl": "http://localhost:8080",
  "testFiles": "**/*.feature",
  "cypress-cucumber-preprocessor": {
    "nonGlobalStepDefinitions": true
  }
}

./cypress/integration/login.feature

Feature: Login Feature

  I want to login

  @focus
  Scenario: Navigate to Login
    Given I open login page
    Then I see Login

./cypress/integration/Login/login.js

./cypress/integration/Login/login.js

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

Given( 'I open login page', () => cy.visit( '/Login' ) );

Then( 'Login page should be shown', () => cy.url().should( 'include', '/Login' ) );

推荐答案

你的 cypress-cucumber-preprocessor 配置应该放在 package.json 中,而不是 cypress.json.

Your cypress-cucumber-preprocessor config should go in package.json, not in cypress.json.

另外,我认为步骤实现文件夹名称必须与功能文件名匹配.因此,您应该将步骤实现文件夹重命名为 login 而不是 Login (./cypress/integration/login/login.js)

Also, I believe the step implementation folder name must match the feature file name. So you should rename your step implementation folder to login instead of Login (./cypress/integration/login/login.js)

查看文档这里