我使用Karma并且要求进行单元测试我注意到一些奇怪的事情。当在行中运行业力3-4次时,我得到2-4个套接字连接。
INFO [karma]: Karma v0.12.2 server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS
WARN [watcher]: Pattern "/Users/mja07/workspace/common-js/test/unit/**/*.mock.js" does not match any file.
INFO [PhantomJS 1.9.7 (Mac OS X)]: Connected on socket 5xynIaiG8NOrpBDAgy34 with id 19375535
INFO [PhantomJS 1.9.7 (Mac OS X)]: Connected on socket amsV702P869uVb23gy35 with id 17909591
这是test-main.js文件:
var tests = Object.keys(window.__karma__.files).filter(function (file) {
return (/(mock|spec)\.js$/).test(file);
});
require.config({
baseUrl: 'base',
paths: {
angular: 'vendor/angular/angular',
'angular-cookies': 'vendor/angular-cookies/angular-cookies',
'angular-mocks': 'vendor/angular-mocks/angular-mocks',
'angular-route': 'vendor/angular-route/angular-route',
'angular-sanitize': 'vendor/angular-sanitize/angular-sanitize',
lodash: 'vendor/lodash/dist/lodash',
mock: 'test/unit/mock',
tweenlite: 'vendor/greensock/src/uncompressed/TweenLite',
'tweenlite-css': 'vendor/greensock/src/uncompressed/plugins/CSSPlugin'
},
shim: {
angular: {
exports: 'angular'
},
lodash: {
exports: '_'
},
tweenlite: {
deps: [
'tweenlite-css'
],
exports: 'TweenLite'
}
}
});
require(['config', 'angular'], function (cfg, A) {
require(['angular-cookies', 'angular-mocks', 'angular-route', 'angular-sanitize'], function () {
A.module(cfg.ngApp, []);
A.bootstrap(document, [cfg.ngApp]);
require(tests, function () {
window.__karma__.start();
});
});
});
还有一个问题,当我得到错误的路径(参见整个路径)时,调试问题的速度有多快:
WARN [web-server]: 404: /vendor/angular/angular.js
PhantomJS 1.9.7 (Mac OS X) ERROR: 'There is no timestamp for vendor/angular/angular.js!'
感谢您的帮助
答案 0 :(得分:1)
问题排序。当Karma崩溃时你仍然有以前的Phantomjs进程,所以你将运行多个phantomjs实例