本文介绍了Cypress.io 和 Cucumber.io 测试集成,缺少步骤实现:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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)

查看文档这里

这篇关于Cypress.io 和 Cucumber.io 测试集成,缺少步骤实现:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 12:51