0
我已经使用webpack with help from this blog post设置了一个Angular项目,其中有an associated boilerplate on Github。未找到Karma + Webpack角度控制器
该应用程序本身工作正常,但是当我运行业力它说它找不到它正在测试的控制器。
// karma.config.js
module.exports = config => config.set({
files: ['test.webpack.js'],
preprocessors: {
'test.webpack.js': ['webpack', 'sourcemap']
},
browsers: ['PhantomJS2'],
webpack: require('./webpack.config'),
webpackMiddleware: {
noInfo: 'errors-only',
},
});
// test.webpack.js
import 'angular';
import 'angular-mocks/angular-mocks';
const testContext = require.context('./', true, /\.spec\.js$/);
testContext.keys().forEach(testContext);
我现在只有一个规格文件MainCtrl.spec.js
。噶将运行它,但我得到的错误:
Argument 'MainCtrl' is not a function, got undefined
当我实际运行的应用程序,MainCtrl
似乎加载就好了,所以我不知道为什么噶不能得到它。
我也试过将\.spec\.js
更改为\.js
,但是这会导致更多的错误。