错误:步骤实现缺失:[step_definition] 尝试使用黄瓜和柏树运行场景时

Seb*_*ian 5 cucumber cypress

我试图做一个简单的测试来尝试黄瓜如何与柏树一起工作,但我没有设法解决标题中描述的问题。

波纹管是我的js文件:

import {Given, When, Then} from "cypress-cucumber-preprocessor/steps"
 
Given('I am in the demo site',()=>{
 
    cy.visit("https://www.saucedemo.com/index.html");
 
})
Run Code Online (Sandbox Code Playgroud)

这是我的功能文件:

Feature: Login Feature
 
Scenario: Login Validation
 
Given I am in the Swag Labs login page
Run Code Online (Sandbox Code Playgroud)

这是问题的屏幕截图 在此处输入图片说明

在尝试了很多东西,但我没有设法解决这个问题。有什么建议?

小智 23

最后,我找到了解决方案。问题出在文件夹结构和命名约定上。以下是我们需要遵循的两个主要规则

  1. 文件夹名称和功能文件名称应该相同
  2. 特征文件和步骤定义不应位于同一文件夹中(stepdefinations/ .js文件应始终位于我们之前创建的文件夹中)。

在此输入图像描述


Dav*_*idz 4

您的步骤定义文件应该是

import {Given, When, Then} from "cypress-cucumber-preprocessor/steps"

Given('I am in the Swag Labs login page',()=>{

    cy.visit("https://www.saucedemo.com/index.html");

})
Run Code Online (Sandbox Code Playgroud)