Javascript 无法在量角器中使用html屏幕截图生成报告
我正在尝试使用量角器中的html屏幕截图生成报告,我已经完成了所有步骤,但遇到了一个错误。请帮忙 我的conf.jsJavascript 无法在量角器中使用html屏幕截图生成报告,javascript,angularjs,node.js,testing,protractor,Javascript,Angularjs,Node.js,Testing,Protractor,我正在尝试使用量角器中的html屏幕截图生成报告,我已经完成了所有步骤,但遇到了一个错误。请帮忙 我的conf.js // An example configuration file. var HtmlReporter = require('protractor-html-screenshot-reporter'); var reporter=new HtmlReporter({ baseDirectory: './protractor-result', // a location to
// An example configuration file.
var HtmlReporter = require('protractor-html-screenshot-reporter');
var reporter=new HtmlReporter({
baseDirectory: './protractor-result', // a location to store screen shots.
docTitle: 'Protractor Demo Reporter',
docName: 'protractor-demo-tests-report.html'
});
exports.config = {
directConnect: true,
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome'
},
// Spec patterns are relative to the current working directly when
// protractor is called.
specs: ['example_spec.js'],
// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000
}
onPrepare: function() {
jasmine.getEnv().addReporter(reporter),
};
};
我收到的错误:意外错误
SyntaxError: Unexpected identifier
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at ConfigParser.addFileConfig (C:\Users\jeevan.s\AppData\Roaming\npm\node_modules\protractor\lib\configParser.js:183:20)
at Object.init (C:\Users\jeevan.s\AppData\Roaming\npm\node_modules\protractor\lib\launcher.js:35:18)
at Object.<anonymous> (C:\Users\jeevan.s\AppData\Roaming\npm\node_modules\protractor\lib\cli.js:129:23)
at Module._compile (module.js:456:26)
SyntaxError:意外的标识符
在模块处编译(Module.js:439:25)
在Object.Module.\u extensions..js(Module.js:474:10)
在Module.load(Module.js:356:32)
在Function.Module.\u加载(Module.js:312:12)
at Module.require(Module.js:364:17)
根据需要(模块js:380:17)
在ConfigParser.addFileConfig(C:\Users\jeevan.s\AppData\Roaming\npm\node\u modules\dragrator\lib\ConfigParser.js:183:20)
在Object.init(C:\Users\jeevan.s\AppData\Roaming\npm\node\u modules\dragrator\lib\launcher.js:35:18)
反对。(C:\Users\jeevan.s\AppData\Roaming\npm\node\u modules\dragrator\lib\cli.js:129:23)
在模块处编译(Module.js:456:26)
您有语法错误:
onPrepare()前面缺少
:,
- 将
替换为,
调用
后的code>addReporter()
- 删除
afteronPrepare()
// An example configuration file.
var HtmlReporter = require('protractor-html-screenshot-reporter');
var reporter=new HtmlReporter({
baseDirectory: './protractor-result', // a location to store screen shots.
docTitle: 'Protractor Demo Reporter',
docName: 'protractor-demo-tests-report.html'
});
exports.config = {
directConnect: true,
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome'
},
// Spec patterns are relative to the current working directly when
// protractor is called.
specs: ['example_spec.js'],
// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000
},
onPrepare: function() {
jasmine.getEnv().addReporter(reporter);
}
};
这个网站对我很有帮助 此修复程序还添加了一个保存路径 我所做的是将以下var添加到Conf.js文件中,并将框架更新为“Jasmine2”,下面是我完整的Conf.js文件:
// conf.js
var Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter');
exports.config = {
framework: 'jasmine2',
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['*.js'],
onPrepare: function() {
jasmine.getEnv().addReporter(
new Jasmine2HtmlReporter({
savePath: 'target/screenshots'
})
);
}
}
希望您在使用之前安装了html screenshot reporter。npm安装量角器html屏幕截图报告器