簡體   English   中英

無法使用 cypress-cucumber-preprocessor 進行標記

[英]Can't get tagging to work with cypress-cucumber-preprocessor

我目前在使用cypress-cucumber-preprocessor package 標記時遇到問題。我知道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未定義。 我究竟做錯了什么?

嘗試使用此命令在 package.json 文件中以這種方式添加腳本:

"scripts": {
    "open:test": "npm run clean:report && cypress open --env configFile=test,TAGS=@test" (or any tag you need)
}

然后將其用作:

npn run open:test

除了將其敲入腳本之外,主要區別在於不使用引號,也許這會對您有所幫助

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM