【发布时间】:2014-09-16 14:46:05
【问题描述】:
我似乎无法让 karma-jasmine 工作。
如果我运行 karma start 我会收到此错误:
Chrome 37.0.2062 (Windows 8.1) 错误未捕获类型错误:无法读取 未定义的属性“clearTimeout”在 [审查]/node_modules/karma-jasmine/lib/jasmine.js:1826
这是我用karma init构建的配置文件。
我已经修改了文件、日志记录和单次运行字段
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: [
'test/jasmine/jasminetest.html',
'lib/bower/jquery/dist/jquery.min.js',
'lib/bower/jasmine/lib/jasmine-core/jasmine.js',
'lib/bower/jasmine/lib/jasmine-core/jasmine-html.js',
'lib/bower/jasmine/lib/jasmine-core/boot.js',
'bin/request.min.js',
'test/jasmine/specs/request/request.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_DEBUG,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,
// 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: true
});
};
这是它似乎窒息的功能
jasmine.getGlobal().clearTimeout = function(timeoutKey) {
if (jasmine.Clock.installed.clearTimeout.apply) {
return jasmine.Clock.installed.clearTimeout.apply(this, arguments);
} else {
return jasmine.Clock.installed.clearTimeout(timeoutKey);
}
};
这里有什么明显的错误吗?我所做的一切都是通过 nodejs 进行库存安装工作。
【问题讨论】:
标签: javascript karma-runner karma-jasmine