html 报告不会在测试完成后生成,即使 json 文件已在 Protractor 中正确生成
The html report is not generated after the tests have finished, even though the json files are generated correctly in Protractor
我正在使用带打字稿的量角器来测试网页,我正在尝试使用包“cucumber-html-reporter”创建一个黄瓜报告,并且生成了 json 但是报告没有。
Cucumberconfig.ts 是:
import { Config } from 'protractor';
import * as reporter from "cucumber-html-reporter";
export let config: Config = {
directConnect: true,//Running chrome
// seleniumAddress: 'http://localhost:4444/wd/hub',
capabilities: {
'browserName': 'chrome'
},
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
// "types": ["chai", "cucumber", "node"],
specs: ['../Features/*.feature'],
cucumberOpts: {
format:'json:./cucumber_report.json',
onComplete: () =>{
var reporter = require('cucumber-html-reporter');
var options = {
theme: 'bootstrap',
jsonFile: './cucumber_report.json',
output: './cucumber_report.html',
scenarioTimestamp: true,
reportSuiteAsScenarios: true,
launchReport: true,
metadata: {
"App Version":"0.3.2",
"Test Environment": "STAGING",
"Browser": "Chrome 54.0.2840.98",
"Platform": "Windows 10",
"Parallel": "Scenarios",
"Executed": "Remote"
},
};
reporter.generate(options);
},
require: [
'../JSFiles/stepDefinitions/*.js' // accepts a glob
]
},
}
并且终端的输出是(成功完成):
量角器cucumberconfig.js
侦听 ws://127.0.0.1:53501/eb7df2a4-ecc9-4d9a-8d9c-4786928a7288 的调试器
如需帮助,请参阅:https://nodejs.org/en/docs/inspector
附加调试器。
[16:00:32] I/launcher - 运行 1 个 WebDriver 实例
[16:00:32] I/direct - 直接使用 ChromeDriver...
DevTools 监听 ws://127.0.0.1:53511/devtools/browser/bc06c50e-96ec-42fb-90ba-516608127bb4
....测试完成
......测试完成
......测试完成
..
3个场景(3个通过)
9个步骤(9个通过)
0m13.468s
[16:00:52] I/launcher - WebDriver 的 0 个实例仍然 运行
[16:00:52] I/launcher - chrome #01 通过
等待调试器断开连接...
这是package.json:
{
"name": "project",
"version": "1.0.0",
"description": "Project one",
"main": "index.js",
"scripts": {
"test": "protractor JSFiles/cucumberconfig.js",
"pretest": "tsc",
"protractor": "./node_modules/protractor/built/cli.js",
"webdriver-update": "./node_modules/.bin/webdriver-manager update"
},
"author": "Carol",
"license": "ISC",
"dependencies": {
"@types/cucumber": "^6.0.1",
"@types/jasmine": "^3.5.11",
"@types/jasminewd2": "2.0.8",
"@types/node": "^14.0.13",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"cucumber": "^6.0.5",
"cucumber-html-report": "^0.6.5",
"jasmine": "~3.5.0",
"protractor-cucumber-framework": "^6.2.1",
"ts-node": "8.10.2",
"typescript": "~3.9.5"
},
"devDependencies": {
"cucumber-html-reporter": "^5.2.0",
"protractor": "^7.0.0"
}
}
有人可以帮我吗?
提前谢谢你。
您将 onComplete
放错了地方。它应该属于配置本身,而不是 cucumberOpts
我不能给你一个可行的解决方案,因为你没有以文本格式附加配置
我正在使用带打字稿的量角器来测试网页,我正在尝试使用包“cucumber-html-reporter”创建一个黄瓜报告,并且生成了 json 但是报告没有。
Cucumberconfig.ts 是:
import { Config } from 'protractor';
import * as reporter from "cucumber-html-reporter";
export let config: Config = {
directConnect: true,//Running chrome
// seleniumAddress: 'http://localhost:4444/wd/hub',
capabilities: {
'browserName': 'chrome'
},
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
// "types": ["chai", "cucumber", "node"],
specs: ['../Features/*.feature'],
cucumberOpts: {
format:'json:./cucumber_report.json',
onComplete: () =>{
var reporter = require('cucumber-html-reporter');
var options = {
theme: 'bootstrap',
jsonFile: './cucumber_report.json',
output: './cucumber_report.html',
scenarioTimestamp: true,
reportSuiteAsScenarios: true,
launchReport: true,
metadata: {
"App Version":"0.3.2",
"Test Environment": "STAGING",
"Browser": "Chrome 54.0.2840.98",
"Platform": "Windows 10",
"Parallel": "Scenarios",
"Executed": "Remote"
},
};
reporter.generate(options);
},
require: [
'../JSFiles/stepDefinitions/*.js' // accepts a glob
]
},
}
并且终端的输出是(成功完成):
量角器cucumberconfig.js 侦听 ws://127.0.0.1:53501/eb7df2a4-ecc9-4d9a-8d9c-4786928a7288 的调试器 如需帮助,请参阅:https://nodejs.org/en/docs/inspector 附加调试器。 [16:00:32] I/launcher - 运行 1 个 WebDriver 实例 [16:00:32] I/direct - 直接使用 ChromeDriver...
DevTools 监听 ws://127.0.0.1:53511/devtools/browser/bc06c50e-96ec-42fb-90ba-516608127bb4 ....测试完成 ......测试完成 ......测试完成 ..
3个场景(3个通过) 9个步骤(9个通过) 0m13.468s [16:00:52] I/launcher - WebDriver 的 0 个实例仍然 运行 [16:00:52] I/launcher - chrome #01 通过 等待调试器断开连接...
这是package.json:
{
"name": "project",
"version": "1.0.0",
"description": "Project one",
"main": "index.js",
"scripts": {
"test": "protractor JSFiles/cucumberconfig.js",
"pretest": "tsc",
"protractor": "./node_modules/protractor/built/cli.js",
"webdriver-update": "./node_modules/.bin/webdriver-manager update"
},
"author": "Carol",
"license": "ISC",
"dependencies": {
"@types/cucumber": "^6.0.1",
"@types/jasmine": "^3.5.11",
"@types/jasminewd2": "2.0.8",
"@types/node": "^14.0.13",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"cucumber": "^6.0.5",
"cucumber-html-report": "^0.6.5",
"jasmine": "~3.5.0",
"protractor-cucumber-framework": "^6.2.1",
"ts-node": "8.10.2",
"typescript": "~3.9.5"
},
"devDependencies": {
"cucumber-html-reporter": "^5.2.0",
"protractor": "^7.0.0"
}
}
有人可以帮我吗?
提前谢谢你。
您将 onComplete
放错了地方。它应该属于配置本身,而不是 cucumberOpts
我不能给你一个可行的解决方案,因为你没有以文本格式附加配置