【发布时间】:2017-11-24 17:46:42
【问题描述】:
我正在尝试在一个项目中运行一周的业力。我已经按照本教程 AngularJS Unit Test 进行操作,但是当运行 karma start 时,控制台会显示此错误:
PhantomJS 2.1.1 (Linux 0.0.0) ERROR
ReferenceError: Can't find variable: angular
at /home/user/workspace/UnitTest/app/app.js:1
我认为问题出在我的项目中,所以我创建了一个新项目,但错误仍然存在。
我的 karma.conf.js 是
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['jasmine'],
files: [
'app/*.js',
'tests/*.js',
'node_modules/angular/angular.js',
'node_modules/angular/angular.min.js',
'node_modules/angular-mocks/angular-mocks.js'
],
exclude: [
],
preprocessors: {
},
reporters: ['progress'],
// web server port
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['PhantomJS'],
customLaunchers: {
Chrome_without_security: {
base: 'PhantomJS',
flags: ['--disable-web-security']
}
},
singleRun: false,
concurrency: Infinity
})
}
和app.js
angular.module('MyApp', [])
.filter('reverse',[function(){
return function(string){
return string.split('').reverse().join('');
}
}])
我也尝试过更改节点版本,但没有成功。
【问题讨论】:
标签: javascript angularjs npm jasmine karma-runner