在linux上运行jenkins运行angular2测试时发生Karma错误
问题描述:
运行与jenkins一起使用karma进行我的angular2单元测试时发现以下错误。在linux上运行jenkins运行angular2测试时发生Karma错误
当我在我的本地机器(Windows)上运行它们时,我的测试运行良好,但是当通过jenkins在Linux上运行测试时,出现以下错误。
Missing error handler on `socket`.
TypeError: (msg || "").replace is not a function
at /home/hudson/.hudson/jobs/workspace/pjt/node_modules/karma/lib/reporter.js:45:23
我的测试从来没有启动任何想法可能会导致这种情况。我查看了业务源代码,我无法弄清楚为什么会有问题。
return function (msg, indentation) {
// remove domain and timestamp from source files
// and resolve base path/absolute path urls into absolute path
msg = (msg || '').replace(URL_REGEXP, function (_, prefix, path, __, ___, line, ____, column) {
if (prefix === 'base') {
path = basePath + path
}
// more code here ...
我正在使用PhantomJS作为测试跑步者,以防本地和jenkins相关。
我很感激任何可能是问题的指针。
答
回答我自己的问题。
原来问题出在我的业力文件部分。
{ pattern: 'node_modules/rxjs/bundles/rx.js', included: true, watched: true }
为RX模块的文件名是node_modules/rxjs /包/ Rx.js
使用Linux是大小写敏感的,这是它的工作在Windows开发环境的原因,未能在Linux构建服务器。
rx.js文件的404消息出现在日志中,但我错过了很多其他调试日志记录。
课学到:)
答
任何人以下https://github.com/juliemr/ng2-test-seed,在我的情况发生,由于这行代码此错误: https://github.com/juliemr/ng2-test-seed/blob/master/karma-test-shim.js#L31。
它更新到System.import('angular2/src/platform/browser/browser_adapter')
会解决问题。 希望它可以帮助别人。
我的第一个直觉是你的本地机器有可用的东西,在Jenkins构建服务器/从属上不可用。你确定buildslave被正确设置为能够运行测试吗?你有没有尝试在该服务器上手动运行它们? – Cronax
@Cronax我还没有直接访问jenkins机器,但我正在获取它。我会尝试手动构建并保持发布。 –