Uncaught ReferenceError: jasmineRequire is not defined
Uncaught ReferenceError: jasmineRequire is not defined
我的测试有问题,当我 运行 他们出现这个错误时:
09 09 2015 14:55:27.174:INFO [Chrome 45.0.2454 (Mac OS X 10.10.1)]: Connected on socket 9aXAoBK8a1zKw9IVAAAA with id 22794373
Chrome 45.0.2454 (Mac OS X 10.10.1) ERROR
Uncaught ReferenceError: jasmineRequire is not defined
at /Users/agarcia/Projects/affiliate-suite/node_modules/karma/jasmine/lib/boot.js:15
这是我的 karma.conf.js 文件:
/*global __dirname*/
// Karma configuration
var path = require('path');
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: __dirname,
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
'node_modules/jasmine-core/lib/jasmine-core/jasmine.js',
'src/**/*.test.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: {
'node_modules/jasmine-core/lib/jasmine-core/jasmine.js': ['webpack'],
'src/**/*.test.js': ['webpack']
},
// 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,
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-webpack')
]
});
};
我已经安装了:
- "jasmine-core": "^2.3.4",
- "karma": "^0.13.9",
- "karma-chrome-launcher": "^0.2.0",
- "karma-jasmine": "^0.3.6",
- "karma-webpack": "^1.7.0",
有什么线索吗?
阅读本文是找到解决此问题的关键:
http://jasmine.github.io/2.0/boot.html
它说 jasmine.js
和 jasmine-html.js
必须在 boot.js
之前加载,所以我所做的就是将它们按顺序排列,它根本不起作用,但我查看 jasmine-core 文件夹,我发现了一个名为 jasmine-core.js
的文件,它以正确的顺序加载所有内容。
完美运行!
您应该更改:
preprocessors: {
'node_modules/jasmine-core/lib/jasmine-core/jasmine.js': [
'webpack'
],
'src/**/*.test.js': ['webpack']
},
至:
preprocessors: {
'src/**/*.test.js': ['webpack']
},
jasmine
将作为 global variables
.
存在
将 jasmine 文件按此顺序排列
/jasmine.css
/jasmine.js
/jasmine-html.js
其次是:
- /boot.js
而且有效。
我的测试有问题,当我 运行 他们出现这个错误时:
09 09 2015 14:55:27.174:INFO [Chrome 45.0.2454 (Mac OS X 10.10.1)]: Connected on socket 9aXAoBK8a1zKw9IVAAAA with id 22794373
Chrome 45.0.2454 (Mac OS X 10.10.1) ERROR
Uncaught ReferenceError: jasmineRequire is not defined
at /Users/agarcia/Projects/affiliate-suite/node_modules/karma/jasmine/lib/boot.js:15
这是我的 karma.conf.js 文件:
/*global __dirname*/
// Karma configuration
var path = require('path');
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: __dirname,
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
'node_modules/jasmine-core/lib/jasmine-core/jasmine.js',
'src/**/*.test.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: {
'node_modules/jasmine-core/lib/jasmine-core/jasmine.js': ['webpack'],
'src/**/*.test.js': ['webpack']
},
// 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,
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-webpack')
]
});
};
我已经安装了:
- "jasmine-core": "^2.3.4",
- "karma": "^0.13.9",
- "karma-chrome-launcher": "^0.2.0",
- "karma-jasmine": "^0.3.6",
- "karma-webpack": "^1.7.0",
有什么线索吗?
阅读本文是找到解决此问题的关键:
http://jasmine.github.io/2.0/boot.html
它说 jasmine.js
和 jasmine-html.js
必须在 boot.js
之前加载,所以我所做的就是将它们按顺序排列,它根本不起作用,但我查看 jasmine-core 文件夹,我发现了一个名为 jasmine-core.js
的文件,它以正确的顺序加载所有内容。
完美运行!
您应该更改:
preprocessors: {
'node_modules/jasmine-core/lib/jasmine-core/jasmine.js': [
'webpack'
],
'src/**/*.test.js': ['webpack']
},
至:
preprocessors: {
'src/**/*.test.js': ['webpack']
},
jasmine
将作为 global variables
.
将 jasmine 文件按此顺序排列
/jasmine.css
/jasmine.js
/jasmine-html.js
其次是:
- /boot.js
而且有效。