JasmineReporters JUnitXmlReporter没有写文件

时间:2014-07-22 21:22:21

标签: angularjs jasmine protractor

我有使用webdriver运行的量角器测试。测试运行,但jasmine-reporter不写输出文件。

protractor_conf.js:

exports.config = {
    // Do not start a Selenium Standalone sever - only run this using chrome.
    //chromeOnly: true,
    //chromeDriver: '../node_modules/protractor/selenium/chromedriver',

    //we are using a standalone selenium server so give it the local address
    seleniumAddress: 'http://0.0.0.0:4444/wd/hub',
    //seleniumPort: 4444,
    //seleniumServerJar: './selenium-server-standalone-2.42.2.jar',


    // Capabilities to be passed to the webdriver instance.
    capabilities: {
        'browserName': 'chrome'
    },

    baseUrl: 'http://localhost:8000',

    onPrepare: function () {
        var jasmineReporters = require('jasmine-reporters');
        var capsPromise = browser.getCapabilities();
        capsPromise.then(function (caps) {
            var browserName = caps.caps_.browserName.toUpperCase();
            var browserVersion = caps.caps_.version;
            var prePendStr = browserName + '-' + browserVersion + '-';
            jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter('test/test-results/protractor', true, true, prePendStr));
        });
    },

    specs: ['test/protractor/**/*-spec.js'],

    // Options to be passed to Jasmine-node.
    jasmineNodeOpts: {
        showColors: true,
        isVerbose: true,
        defaultTimeoutInterval: 30000
    },

    params: {
        env: 'development',
        homepageUrl: 'http://localhost:9000'
    }
};

测试输出:

/usr/local/bin/node --debug-brk=60603 --nolazy node_modules/protractor/lib/cli.js protractor_conf-dev.js
debugger listening on port 60603
Using the selenium server at http://0.0.0.0:4444/wd/hub
E2E: verify main page loads and correct items are there
  when the main page loads, the content should be available - pass


Finished in 0.727 seconds
1 test, 1 assertion, 0 failures


Process finished with exit code 0

enter image description here

1 个答案:

答案 0 :(得分:2)

看起来很像你试图将jasmine-reporters@2.0.0与量角器结合起来。量角器目前支持Jasmine 1.x,而不是Jasmine 2.x.我怀疑你想使用~1.0.0茉莉花 - 记者。看起来你也试图将jasmine-reporter 1.x语法与2.x记者结合起来。

  • 由于var jasmineReporters = require('jasmine-reporters');new jasmineReporters.JUnitXmlReporter( /* ... */ );,您似乎正在使用2.0.0
    • jasmine-reporter 1.x没有index.js并且没有导出任何内容,所以如果使用1.x记者尝试上述代码,您应该获得TypeError: undefined is not a function
  • 看起来您正在将1.x语法与2.x记者结合使用,因为2.x JUnitXmlReporter需要配置对象而不是有序参数。

如果您使用jasmine-reporter 1.x:

,您的代码应该看起来更像这样
require('jasmine-reporters');
jasmine.getEnv().addReporter(
    new jasmine.JUnitXmlReporter('test/test-results/protractor', true, true, prePendStr)
);