如何将脚本部分修改为 exclude/skip scenarion with tag @ignore in package.json

How to modify scripts section to exclude/skip scenarion with tag @ignore in package.json

我需要 运行 使用 puppeteer 和 chai 进行黄瓜测试,但排除带有 @ignore 标签的场景。

这应该可以在 package.json 下的脚本和 "test" 行中设置。但是我不知道怎么...

这是代码

{
  "name": "cucumber-puppeteer-example",
  "description": "Example project on how to use cucumber with puppeteer",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "scripts": {
    "build": "rimraf build out && tsc",
    "build:watch": "rimraf build && tsc -w",
    "test": "cucumber-js --require \"build/**/*.js\"",
    "test:headless": "cross-env CLS_TEST_HEADLESS=false cucumber-js --require \"build/**/*.js\"",
    "test:local": "rimraf out && cross-env CLS_TEST_HEADLESS=false CLS_TEST_URL=http://localhost:4200 cucumber-js --require \"build/**/*.js\"",
    "e2e": "ts-node",
    "chromium": "ts-node ci-chromium-install.ts linux 641577",
    "lint": "tslint --project tsconfig.json -c tslint.json"
  },
  "devDependencies": {
    "@types/chai": "4.1.7",
    "@types/cucumber": "4.0.5",
    "@types/puppeteer": "1.12.3",
    "chai": "4.2.0",
    "chromium": "^2.1.0",
    "cross-env": "5.2.0",
    "cucumber": "5.1.0",
    "puppeteer": "1.14.0",
    "ts-node": "8.0.3",
    "tslint": "^5.16.0",
    "tslint-no-unused-expression-chai": "^0.1.4",
    "typescript": "3.3.4000",
    "unzip": "0.1.11"
  }
}

任何人都知道如何将这样的东西放在 ~@ingore 以忽略此处所有标记的场景 package.json?

在你的钩子上添加一个前步骤 return 'pending'

创建一个单独的 class,名称为 cucumberOpts.ts/ js,如下所示:

{
"compiler": "ts:ts-node/register",
"projectName": {
    "tags": {
        "ui": ["@Ui", "~@Ignore"],
        "api": ["@Api", "~@Ignore"]
    }
}

}

并在您的 package.json 文件中使用此 class,如下所示:

"scripts": {
"e2e": "cucumber-js ./src/test/features --cucumberOpts.compiler -f node_modules/cucumber-pretty --format json:cucumber-json-report.json --cucumberOpts.projectName.tags.ui"

}

在您需要跳过的场景之前使用@Ignore 标记,并从您的终端使用运行 'npm run e2e' 命令。这将考虑所有带有@Ui 标记的场景,并将跳过所有带有@Ignore 标记的功能。如果您在同一场景中包含这两个标签,将跳过该场景