簡體   English   中英

如何在 nrwl nx 工作區中使用標簽運行 cypress 測試

[英]How to run cypress tests with tags in nrwl nx workspace

我在 nrwl nx 工作區工作,我在其中設置了 cypress BDD cucumber 項目。 我需要使用 nrwl 基於標簽運行 cypress 測試。

通常我會使用 cypress-tags 命令來做同樣的事情:例如: "cypress run --env TAGS='@smoke' --browser chrome

我將相同的邏輯應用於 nx 命令。 例如: nx e2e myProject-e2e --tags=@reg

但是 nx 項目正在識別 cypress 中的所有測試用例,它沒有考慮標記為“@reg”標簽的測試用例

如果 nrwl 中有規定可以根據標簽運行 cypress 測試,有人可以指導我嗎

我遇到了同樣的問題,並通過使用NX 配置中的 ENV object 得到了解決方法:

這樣,我在project.json配置文件中添加了標簽,在我的例子中,用於運行煙霧測試和基於標簽過濾的回歸測試:

"smoke": {
  "executor": "@nrwl/cypress:cypress",
  "options": {
    "cypressConfig": "apps/explore-e2e/cypress.json",
    "baseUrl": "<BASE_URL>",
    "env": {
      "TAGS": "@smoke"
    }
  },
  "configurations": {
    "staging": {
      "baseUrl": "<STG_URL>"
    },
    "production": {
      "baseUrl": "<PROD_URL>"
    }
  }
},
"regression": {
  "executor": "@nrwl/cypress:cypress",
  "options": {
    "cypressConfig": "apps/explore-e2e/cypress.json",
    "baseUrl": "<BASE_URL>",
    "env": {
      "TAGS": "@regression"
    }
  },
  "configurations": {
    "staging": {
      "baseUrl": "<STG_URL>"
    },
    "production": {
      "baseUrl": "<PROD_URL>"
    }
  }
}

有了這個,您現在可以開始標記您的場景並運行它:

nx e2e myProject-e2e:smoke --TAGS=@smoke

(在我的情況下,我使用的是: yarn nx run代替)

暫無
暫無

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

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