的NodeJS量角器+茉莉+ JUnitXmlReporter运行测试而无需等待浏览器 [英] Nodejs Protractor + Jasmine + JUnitXmlReporter runs the test but without waiting for the browser

查看:406
本文介绍了的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.

https://github.com/larrymyers/jasmine-reporters#protractor

这篇关于的NodeJS量角器+茉莉+ JUnitXmlReporter运行测试而无需等待浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆