【问题标题】:Can't get tagging to work with cypress-cucumber-preprocessor无法使用 cypress-cucumber-preprocessor 进行标记
【发布时间】: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


    【解决方案1】:

    尝试以这种方式在 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
    

    除了将其敲入脚本之外,主要区别在于不使用引号,也许这会对您有所帮助

    【讨论】:

      猜你喜欢
      • 2022-11-10
      • 1970-01-01
      • 2022-09-30
      • 2022-06-28
      • 2023-02-21
      • 1970-01-01
      • 2023-01-31
      • 1970-01-01
      • 2021-08-07
      相关资源
      最近更新 更多