简体   繁体   中英

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.

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 |
And my step definitions:

 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. What am I doing wrong?

Try to add script with this command in package.json file this way:

"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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM