我试图做一个简单的测试来尝试黄瓜如何与柏树一起工作,但我没有设法解决标题中描述的问题。
波纹管是我的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 pageRun Code Online (Sandbox Code Playgroud)
这是问题的屏幕截图

在尝试了很多东西,但我没有设法解决这个问题。有什么建议?
小智 23
最后,我找到了解决方案。问题出在文件夹结构和命名约定上。以下是我们需要遵循的两个主要规则
stepdefinations/ .js文件应始终位于我们之前创建的文件夹中)。
您的步骤定义文件应该是
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)