的NodeJS量角器+茉莉+ JUnitXmlReporter运行测试而无需等待浏览器
Im做到底用量角器结束角网站的测试,但要导出结果的文件詹金斯可以读取(JUnitXmlReporter),所以对于这个工作,我需要做的,我的量角器一个简单的变化在关于prepare配置文件:
Im doing end to end testing of a Angular website using protractor, but wanted to export the results to a file that Jenkins can read (JUnitXmlReporter), so for this to work I need to do a "simple change" to my protractor config file on the "onPrepare":
exports.config = {
// Do not start a Selenium Standalone sever - only run this using chrome.
framework: 'jasmine',
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome'
},
specs: [
'./test1.js',
'./test2.js'
],
// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
showColors: true,
isVerbose: true
},
onPrepare: function() {
var jasmineReporters = require('jasmine-node-reporter-fix');
jasmine.getEnv().addReporter(
new jasmineReporters.JUnitXmlReporter('protractor_output', true, true, 'testresults.e2e.');
}
};
但一旦我在preparecode,所有的试运行添加此无需等待浏览器呈现HTML 。如果我删除了preparecode,所有的测试将开始工作不如预期,但詹金斯生成任何文件。
but once I add this "onPrepare" code, all the test run without waiting for the browser to render the html. If I remove the "onPrepare" code, all the test will start working as expected, but no files generated for jenkins.
任何想法什么错?
您可能需要等待浏览器的承诺。
You may need to wait for the browser's promise.
onPrepare: function() {
var jasmineReporters = require('jasmine-node-reporter-fix');
var capsPromise = browser.getCapabilities();
capsPromise.then(function (caps) {
jasmine.getEnv().addReporter(
new jasmineReporters.JUnitXmlReporter(
'protractor_output', true, true, 'testresults.e2e.');
}
}
这是说,如果你使用的是量角器,那么你可能需要调用 JUnitXmlReporter
关闭茉莉
对象,不是 jasmineReporters
。我没有使用节点茉莉
或茉莉花节点记者修复
,所以我不能说记者得到的导出方式,但茉莉花记者:〜1.0.0
记者仍然附着在茉莉
对象。
That said, if you are using Protractor, then you may need to call the JUnitXmlReporter
off the jasmine
object, not jasmineReporters
. I'm not using node-jasmine
or jasmine-node-reporter-fix
, so I can't speak to how the reporter gets exported, but on "jasmine-reporters":"~1.0.0"
the reporter was still attached to the jasmine
object.