[英]Can't get tagging to work with cypress-cucumber-preprocessor
I am currently having issues with using tagging with the cypress-cucumber-preprocessor
package. I know that the cypress-tags
has been removed and made redundant so I'm trying to set up tagging using the new syntax but to no avail.我目前在使用
cypress-cucumber-preprocessor
package 标记时遇到问题。我知道cypress-tags
已被删除并变得多余,所以我尝试使用新语法设置标记但无济于事。
Here is my feature:这是我的特点:
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" ); });
When I try to run my tests with npx cypress run --env tags="@google"
, it gives me an error saying url
in my steps definitions isn't defined.当我尝试使用
npx cypress run --env tags="@google"
运行我的测试时,它给我一个错误,指出我的步骤定义中的url
未定义。 What am I doing wrong?我究竟做错了什么?
Try to add script with this command in package.json file this way:尝试使用此命令在 package.json 文件中以这种方式添加脚本:
"scripts": {
"open:test": "npm run clean:report && cypress open --env configFile=test,TAGS=@test" (or any tag you need)
}
And then use it as:然后将其用作:
npn run open:test
The main difference besides rapping it into script is not using quotes, maybe this will help you除了将其敲入脚本之外,主要区别在于不使用引号,也许这会对您有所帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.