我们在共享代码的多个不同项目中使用闭包库。我们现在在其中一个项目中开始使用 AngularJS,我们正在尝试让 Karma runner 正常工作。
我已经听从了这篇文章的建议,但不能让它一直工作。 如何配置 karma-runner(也称为 testacular)以使用闭包库
它正在运行 goog.require('my.namespaced.file') 但是当 my/namespaced/file.js 有一个 goog.require('goog.dom') 或来自闭包库的东西时,Karma 跑步者会吐出这个...
Starting Karma Server (http://karma-runner.github.io)
-------------------------------------------------------------------
INFO [karma]: Karma v0.9.2 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
NOT SERVED FILE undefined
INFO [Chrome 27.0 (Mac)]: Connected on socket id 3tRuxHEhooSb458fJnFt
ERROR [karma]: [TypeError: Cannot call method 'indexOf' of undefined]
TypeError: Cannot call method 'indexOf' of undefined
at /usr/local/lib/node_modules/karma/lib/web-server.js:103:28
at Array.map (native)
at /usr/local/lib/node_modules/karma/lib/web-server.js:91:43
at /usr/local/lib/node_modules/karma/lib/web-server.js:37:35
at fs.js:266:14
at Object.oncomplete (fs.js:107:15)
这是我的 karma.conf.js 文件
basePath = '../../../../';
// frameworks to use
frameworks = ['jasmine', 'closure'];
// list of files / patterns to load in the browser
files = [
// closure base
{pattern: 'closure-library/closure/goog/base.js', watched: false, included: true, served: true},
{pattern: 'ne-js/src/main/js/ne-js.deps.js', watched: false, included: true, served: true},
{pattern: 'angular-ne/src/main/js/angular-ne.deps.js', watched: false, included: true, served: true},
{pattern: 'ne-webServices/src/main/js/ne-webServices.deps.js', watched: false, included: true, served: true},
{pattern: 'directives/src/main/js/directives.deps.js', watched: false, included: true, served: true},
{pattern: 'webapp/src/main/js/webapp.deps.js', watched: false, included: true, served: true},
{pattern: 'webapp/src/test/lib/angular.js', watched: false, included: false, served: true},
{pattern: 'webapp/src/test/lib/angular-mocks.js', watched: false, included: false, served: true},
{pattern: 'webapp/src/main/js/**/*.js', watched: true, included: false, served: true},
{pattern: 'webapp/src/test/js/**/*.js', watched: true, included: true, served: true},
];
preprocessors = {
'webapp/src/test/js/**/*.js': ['closure', 'closure-iit'],
'webapp/src/main/js/**/*.js': ['closure'],
};
autoWatch = true;
browsers = ['Chrome'];
// plugins to load
plugins = [
'testacular-closure',
'karma-jasmine',
'karma-chrome-launcher',
'karma-phantomjs-launcher',
];