在詹金斯上运行量角器测试

时间:2015-03-04 15:27:50

标签: angularjs selenium gruntjs jasmine protractor

我正在尝试使用jasmine-reporter插件为jenkins生成报告。

我的量角器配置是:

exports.config = {
allScriptsTimeout: 99999,
seleniumAddress: 'http://localhost:4444/wd/hub',
capabilities: {
    'browserName': 'chrome'
},
baseUrl: 'http://localhost:9000/',
framework: 'jasmine2',
specs: ['../test/e2e/**/*.js'],
onPrepare: function() {
   var jasmineReporters = require('jasmine-reporters');
    jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
        consolidateAll: true,
        filePrefix: 'test_results_e2e'
    }));
},

jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 60000,
    print: function() {}
}
};

生成带有测试报告的文件,但测试失败并出现以下错误:

Failed: Angular could not be found on the page http://localhost:9000/# : retries looking for angular exceeded

我正在使用咕噜声。所以我定义了两个任务,一个用于测试,第二个用于开发。这两个任务使用不同的配置文件,唯一的区别是执行" grunt test"应该是文件报告,而" grunt dev"执行测试并监视更改。所以,如果我用" dev"运行应用程序任务然后我没有得到任何错误。但仍然是任务"测试"生成错误的文件。

1 个答案:

答案 0 :(得分:1)

您看到的错误表明您正在测试的网页不是Angular应用。根据您提供的信息,我最好的猜测是您的grunt dev任务正在启动本地服务器并在端口9000上为您的应用程序提供服务,这样可以使测试正常运行,但您的grunt test任务不会启动本地服务器,因此您的应用程序实际上并未在端口9000上运行。

相关问题