gpt4 book ai didi

node.js - 在单个配置文件中报告 'protractor-jasmine2-screenshot-reporter' 和 'jasmine-reporters',但 Jasmine2-Screenshot 报告器不起作用

转载 作者:太空宇宙 更新时间:2023-11-04 02:16:11 24 4
gpt4 key购买 nike

下面是包含“protractor-jasmine2-screenshot-reporter”和“jasmine-reporter”的配置文件

它单独工作正常,但如果我结合使用 protractor-jasmine2-screenshot-reporter' 则不起作用,是因为我有两个 'onPrepare' 功能

 var HtmlScreenshotReporter = require('C:/Protractor_Scripts/node_modules/protractor-jasmine2-screenshot-reporter');

var reporter = new HtmlScreenshotReporter({
dest: 'C:/Protractor_Scripts/Screenshots',
filename: 'Report.html'
});

exports.config = {

directConnect: false,

multiCapabilities: [


{'browserName': 'chrome'},
{'browserName': 'firefox'}

],

allScriptsTimeout: 1200000,

framework: 'jasmine2',

specs: ['C:/Protractor_Scripts/Protractor/Driver/Driver.js'],

// Setup the report before any tests start
beforeLaunch: function() {
return new Promise(function(resolve){
reporter.beforeLaunch(resolve);
});
},


onPrepare: function() {
jasmine.getEnv().addReporter(reporter);
},

// Close the report after all tests finish
afterLaunch: function(exitCode) {
return new Promise(function(resolve){
reporter.afterLaunch(resolve.bind(this, exitCode));
});
},


Jasmine Reporter which is used to generate xml reports
onPrepare: function() {

var jasmineReporters = require('C:/Protractor_Scripts/node_modules/jasmine-reporters');
jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
consolidateAll: true,
savePath: 'C:/Protractor_Scripts/Results',
filePrefix: 'xmloutput'
}));
},

// ----- Options to be passed to minijasminenode -----
jasmineNodeOpts: {
// onComplete will be called just before the driver quits.
onComplete: null,
// If true, display spec names.
isVerbose: false,
// If true, print colors to the terminal.
showColors: true,
// If true, include stack traces in failures.
includeStackTrace: true,
// Default time to wait in ms before a test fails.
defaultTimeoutInterval: 1200000
}

};

最佳答案

不要定义两个 onPrepare 函数,将所有内容放入一个函数中:

onPrepare: function() {
jasmine.getEnv().addReporter(reporter);

var jasmineReporters = require('C:/Protractor_Scripts/node_modules/jasmine-reporters');
jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
consolidateAll: true,
savePath: 'C:/Protractor_Scripts/Results',
filePrefix: 'xmloutput'
}));
},

关于node.js - 在单个配置文件中报告 'protractor-jasmine2-screenshot-reporter' 和 'jasmine-reporters',但 Jasmine2-Screenshot 报告器不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35605091/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com