我正在使用 Karma 和 Require 进行单元测试我注意到一些奇怪的事情。当连续运行 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!'
感谢帮助