【发布时间】:2023-02-02 21:24:39
【问题描述】:
我目前在使用 cypress-cucumber-preprocessor 包标记时遇到问题。我知道 cypress-tags 已被删除并变得多余,所以我尝试使用新语法设置标记但无济于事。
这是我的特点:
Feature: duckduckgo.com
Rule: I am on a desktop
Scenario: visiting the frontpage
When I visit <site>
Then I should see a search bar
@google
Examples:
| site |
| google.com |
@duckduckgo
Examples:
| site |
| duckduckgo.com |
import { When, Then } from "@badeball/cypress-cucumber-preprocessor";
When(`I visit` + url, () => {
if(url === 'duckduckgo.com') return cy.visit("https://www.duckduckgo.com");
if(url === 'google.com') return cy.visit("https://www.google.com");
});
Then("I should see a search bar", () => {
cy.get("input").should(
"have.attr",
"placeholder",
"Search the web without being tracked"
);
});
当我尝试使用 npx cypress run --env tags="@google" 运行我的测试时,它给我一个错误,指出我的步骤定义中的 url 未定义。我究竟做错了什么?
【问题讨论】:
标签: cypress cypress-cucumber-preprocessor