protractor-jasmine2-screenshot-reporter如果所有的测试通过和Config文件都有' captureOnlyFailedSpecs:true'已启用
配置文件:
exports.config = {
allScriptsTimeout: 30000,
suites: {
full: 'e2e/**/*.js'
},
multiCapabilities: [
{'browserName': 'chrome'}
],
directConnect : true,
baseUrl: 'http://mytesturl:8080/',
framework: 'jasmine2',
jasmineNodeOpts: {
defaultTimeoutInterval: 30000
},
onPrepare: function() {
browser.driver.manage().window().maximize();
return browser.getProcessedConfig().then(function(config) {
var browserName = config.capabilities.browserName;
var HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter');
var reporter = new HtmlScreenshotReporter({
dest: 'tests/test-results/screenshots',
filename: 'E2E-report.html',
showSummary: true,
showQuickLinks: true,
captureOnlyFailedSpecs: true,
pathBuilder: function(currentSpec, suites, browserCapabilities) {
return browserCapabilities.get('browserName') + '/' + currentSpec.fullName;
},
});
jasmine.getEnv().addReporter(reporter);
});
},
};
如果所有测试通行证和/ screenshots文件夹都不存在,那么它不会创建/ screenshots文件夹。 如果测试失败和/屏幕截图不存在,则记者创建/ screenshots文件夹并将屏幕截图和html报告保存在此文件夹下。
如果所有测试通过并且/ screenshots文件夹不存在,我将收到以下错误:
Error: ENOENT: no such file or directory, open 'C:\ui\dgui\tests\test-results\screenshots\E2E-report.html'
at Error (native)
at Object.fs.openSync (fs.js:549:18)
at Object.fs.writeFileSync (fs.js:1156:15)
at Object.fs.appendFileSync (fs.js:1204:6)
at Jasmine2ScreenShotReporter.jasmineDone (C:\ui\dgui\node_modules\protractor-jasmine2-screenshot-reporter\index.js:499:10)
at dispatch (C:\ui\dgui\node_modules\protractor\node_modules\jasmine\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1869:28)
at C:\ui\dgui\node_modules\protractor\node_modules\jasmine\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1852:11
at QueueRunner.clearStack (C:\ui\dgui\node_modules\protractor\node_modules\jasmine\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:605:9)
at QueueRunner.run (C:\ui\dgui\node_modules\protractor\node_modules\jasmine\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1784:12)
at C:\ui\dgui\node_modules\protractor\node_modules\jasmine\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1801:16
From: Task: WebDriver.manage().window().maximize()
at [object Object].webdriver.WebDriver.schedule (C:\ui\dgui\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:362:15)
at [object Object].webdriver.WebDriver.Window.maximize (C:\ui\dgui\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:1476:23)
at exports.config.onPrepare (C:\ui\dgui\tests\protractor-conf-IncidentPanel.js:73:35)
at C:\ui\dgui\node_modules\protractor\lib\util.js:56:41
at Function.promise (C:\ui\dgui\node_modules\protractor\node_modules\q\q.js:650:9)
at Object.exports.runFilenameOrFn_ (C:\ui\dgui\node_modules\protractor\lib\util.js:46:12)
at [object Object].Runner.runTestPreparer (C:\ui\dgui\node_modules\protractor\lib\runner.js:76:17)
at Object.exports.run (C:\ui\dgui\node_modules\protractor\lib\frameworks\jasmine2.js:89:17)
at C:\ui\dgui\node_modules\protractor\lib\runner.js:333:35
at _fulfilled (C:\ui\dgui\node_modules\protractor\node_modules\q\q.js:797:54)
[launcher] Process exited with error code 1
答案 0 :(得分:1)
好像有人已经在他们的github上发布了一个问题:https://github.com/mlison/protractor-jasmine2-screenshot-reporter/issues/65
我能够通过降级到protractor-jasmine2-screenshot-reporter@0.2.0来解决这个问题