茉莉花测试返回错误“未捕获的引用错误:未定义要求”
Jasmine Test returns error "Uncaught ReferenceError: require is not defined"
首先,我知道这个问题在其他时候被问过,但它似乎有所不同。
这是我的业力配置文件:
// Karma configuration
// Generated on Thu Jan 21 2016 09:58:23 GMT-0300 (Argentina Standard Time)
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
'src/*.js',
'test/*.js',
'src/*.js',
'tests/*.js'
],
// list of files to exclude
exclude: [
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,
// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
})
}
这是我到目前为止的测试,以使其工作:
require('../src/person.js');
describe('Person ', function(){
it('Should say hi with proposed first name and last name', function() {
var person = new person();
expect(true).toEqual(true);
});
});
当我运行业力时,我收到错误说require is not defined
。无论如何,karma-requirejs
都是由npm
全局安装的。
我正在阅读这个问题,似乎是同样的问题:茉莉花测试给出错误"未捕获的引用错误:未定义要求"
但是添加后
plugins : [
'karma-requirejs',
],
到业力康普文件,我还有很多其他错误,似乎它不认识这个属性?
如何修复该错误?
我建议在项目的根目录中安装karma-requirejs
,或者将所有其他npm模块安装在项目本地的位置。
相关文章:
- gmaps4rails 2.4.6未捕获引用错误:未定义Gmaps
- Wordpress中的Javascript出现匿名函数/引用错误
- 使用dc.js、d3.js和crossfilter引用错误
- 未捕获引用错误:未定义validateform
- 为什么我会出现此错误"未捕获引用错误:未定义标题;
- $未定义-未捕获引用错误
- Sitecore”;未捕获引用错误:未定义MultilistWithSearch;
- Wordpress:未捕获引用错误:未定义速度
- Node.js引用错误:未定义类名
- 我该如何解决“;未捕获引用错误:谷歌没有定义"?(谷歌地图API)
- Javascript 未定义错误:引用错误:未定义 ALT
- 为流星重新包装砌体会产生错误“引用错误:窗口未定义”
- 未定义错误引用
- 错误: 引用错误: 未定义发送
- 角度砌体指令隐藏内部元素,错误:引用错误:未定义砌体
- CoffeeScript 在 'for v in values' 中创建一个全局变量 'v',导致事件中的错误引用
- Javascript:未捕获类型错误:引用创建的对象时无法调用未定义的方法“add”
- 架构错误 - 引用错误:未定义电话
- 获取错误“引用错误:未定义事件”
- 打字稿错误引用_this