我正在使用 Karma 和 PhantomJS 和 Jasmine 来测试我的 AngularJS。当我在本地运行我的 gulp 测试时,它工作正常,启动 PhantomJS 并运行我所有的测试,但是当测试在构建服务器上运行时,它失败并出现以下错误:
请注意,我正在使用 VSTS 并使用他们内置的云构建系统(托管代理)。话虽如此,它几乎是一个任务运行器,我只用它在签入时运行 gulp 任务(构建、测试等)
[32m13 07 2016 15:21:32.260:INFO [karma]: [39mKarma v1.1.1 server started at http://localhost:9876/
[32m13 07 2016 15:21:32.262:INFO [launcher]: [39mLaunching browser PhantomJS with unlimited concurrency
[32m13 07 2016 15:21:32.284:INFO [launcher]: [39mStarting browser PhantomJS
[33m13 07 2016 15:22:32.285:WARN [launcher]: [39mPhantomJS have not captured in 60000 ms, killing.
[33m13 07 2016 15:22:34.287:WARN [launcher]: [39mPhantomJS was not killed in 2000 ms, sending SIGKILL.
[33m13 07 2016 15:22:36.288:WARN [launcher]: [39mPhantomJS was not killed by SIGKILL in 2000 ms, continuing.
我的业力配置是:
var configuration = {
basePath: "",
files: listFiles(),
singleRun: true,
autoWatch: false,
//usePolling: true,
//transports: ["xhr-polling", "jsonp-polling"],
frameworks: ["jasmine", "angular-filesort"],
angularFilesort: {
whitelist: [path.join(conf.paths.src, "/**/!(*.html|*.spec|*.mock).js")]
},
ngHtml2JsPreprocessor: {
stripPrefix: "src/",
moduleName: "veriApp"
},
browsers: ["PhantomJS"],
//browsers: ["Chrome"],
plugins: [
"karma-chrome-launcher",
"karma-phantomjs-launcher",
"karma-angular-filesort",
"karma-jasmine",
"karma-ng-html2js-preprocessor"
],
preprocessors: {
"src/**/*.html": ["ng-html2js"]
}
};
这是我的 package.json 的相关部分。请注意,在运行测试之前执行 NPM 安装
"karma": "1.1.1",
"karma-angular-filesort": "1.0.0",
"karma-jasmine": "1.0.2",
"karma-ng-html2js-preprocessor": "1.0.0",
"phantomjs-prebuilt": "2.1.4",
"karma-phantomjs-launcher": "1.0.0",
"karma-chrome-launcher": "1.0.1",
我已经尝试从有关此的各种答案中获得建议,但似乎没有一个有效!也许我错过了什么?