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

Cypress.io and Cucumber.io testing integration, Step implementation missing for:

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

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: 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

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.

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

参见文档 here

虽然我不认为这个答案是理想的,但我设法通过从 cypress.json 中删除 "cypress-cucumber-preprocessor" 并将子目录从 "cypress/integration" 目录移动到 [=14] =]

在您的 package.json 中添加 step_defintions 自定义路径

"cypress-cucumber-preprocessor": {
   "step_definitions": "cypress/integration/features/step_definitions/**/"
}