项目目录结构:
karma的配置如下:
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['mocha'],
files: [
'./test/unit/**/**.spec.js'
],
exclude: [
],
preprocessors: {
},
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
concurrency: Infinity
})
}
在test/unit/a.spec.js中,测试用例代码:
var assert = require('assert');
describe('Array', function() {
describe('#indexOf()', function() {
it('should return -1 when the value is not present', function() {
assert.equal(-1, [1,2,3].indexOf(4));
});
});
});
在启动karma的时候,总会报错:
Uncaught Error: Cannot find module 'assert'
at node_modules/mocha/mocha.js:1
请大神指教,不知哪里配置有问题?