我需要使用puppeteer和chai运行黄瓜测试,但要排除带有标签@ignore的情况。
这可能应该在package.json中的脚本和“测试”行下进行设置。但是我不知道如何...
这是代码
{
"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中,以忽略此处所有标记的情况吗?
答案 0 :(得分:1)
在钩子上添加前一个步骤并返回“待处理”
答案 1 :(得分:1)
使用如下名称创建一个单独的类,名称为CucumberOpts.ts / js:
{
"compiler": "ts:ts-node/register",
"projectName": {
"tags": {
"ui": ["@Ui", "~@Ignore"],
"api": ["@Api", "~@Ignore"]
}
}
}
并在package.json文件中使用此类,如下所示:
"scripts": {
"e2e": "cucumber-js ./src/test/features --cucumberOpts.compiler -f node_modules/cucumber-pretty --format json:cucumber-json-report.json --cucumberOpts.projectName.tags.ui"
}
在您需要从终端跳过并运行'npm run e2e'命令的场景之前,使用@Ignore标记。这将考虑所有用@Ui标记的场景,并跳过所有用@Ignore标记的功能。如果您同时包含同一场景的两个标签,则会跳过该场景