我有一个我正在整理的 AngularJS 项目。应用程序正常运行和执行。测试在本地运行和执行。在 AWS CodeBuild 上进行构建时,我的日志中出现以下错误:
[Container] 2017/01/17 21:54:36 [21:54:36] Starting 'karma:single-run'...
[Container] 2017/01/17 21:54:37 [32m17 01 2017 21:54:37.350:INFO [karma]: [39mKarma v1.3.0 server started at http://localhost:9876/
[Container] 2017/01/17 21:54:37 [32m17 01 2017 21:54:37.351:INFO [launcher]: [39mLaunching browser PhantomJS with unlimited concurrency
[Container] 2017/01/17 21:54:37 [32m17 01 2017 21:54:37.356:INFO [launcher]: [39mStarting browser PhantomJS
[Container] 2017/01/17 21:55:37 [33m17 01 2017 21:55:37.417:WARN [launcher]: [39mPhantomJS have not captured in 60000 ms, killing.
[Container] 2017/01/17 21:55:39 [33m17 01 2017 21:55:39.421:WARN [launcher]: [39mPhantomJS was not killed in 2000 ms, sending SIGKILL.
[Container] 2017/01/17 21:55:41 [33m17 01 2017 21:55:41.424:WARN [launcher]: [39mPhantomJS was not killed by SIGKILL in 2000 ms, continuing.
我运行相同的 Gulp 任务以在两个位置执行测试:
process.env.NODE_ENV = 'test';
const path = require('path');
const gulp = require('gulp');
const karma = require('karma');
gulp.task('karma:single-run', karmaSingleRun);
gulp.task('karma:auto-run', karmaAutoRun);
function karmaFinishHandler(done) {
return failCount => {
done(failCount ? new Error(`Failed ${failCount} tests.`) : null);
};
}
function karmaSingleRun(done) {
const configFile = path.join(process.cwd(), 'conf', 'karma.conf.js');
const karmaServer = new karma.Server({configFile}, karmaFinishHandler(done));
karmaServer.start();
}
function karmaAutoRun(done) {
const configFile = path.join(process.cwd(), 'conf', 'karma-auto.conf.js');
const karmaServer = new karma.Server({configFile}, karmaFinishHandler(done));
karmaServer.start();
}
我的 karma.conf.js 文件也是一样的:
const conf = require('./gulp.conf');
module.exports = function (config) {
const configuration = {
basePath: '../',
singleRun: true,
browserDisconnectTimeout: 10000,
browserNoActivityTimeout: 20000,
failOnEmptyTestSuite: false,
autoWatch: true,
logLevel: 'INFO',
junitReporter: {
outputDir: 'test-reports'
},
browsers: [
'PhantomJS'
],
frameworks: [
'jasmine',
'jspm',
'es6-shim'
],
preprocessors: {
[conf.path.src('**/*.html')]: [
'ng-html2js',
'generic'
]
},
genericPreprocessor: {
rules: [
{
process(content, file, done) {
file.path = file.path.replace(/\.js$/, '.ts');
done(content);
}
}
]
},
ngHtml2JsPreprocessor: {},
jspm: {
loadFiles: [
conf.path.src('app/**/*.ts'),
conf.path.src('**/*.html')
],
config: 'jspm.config.js',
browser: 'jspm.test.js'
},
plugins: [
require('karma-jasmine'),
require('karma-junit-reporter'),
require('karma-coverage'),
require('karma-phantomjs-launcher'),
require('karma-phantomjs-shim'),
require('karma-ng-html2js-preprocessor'),
require('karma-jspm'),
require('karma-generic-preprocessor'),
require('karma-es6-shim')
]
};
config.set(configuration);
};
知道发生了什么吗?
值得一提的是,我的本地项目在 Windows 上,而亚马逊上的 Node 实例在 Ubuntu 上运行。会不会是一些奇怪的文件系统或版本问题?