gpt4 book ai didi

javascript - karma-jasmine 无法读取属性 'clearTimeout'

转载 作者:行者123 更新时间:2023-12-03 11:50:20 25 4
gpt4 key购买 nike

我似乎无法让 karma-jasmine 工作。

如果我运行 karma start 我会收到此错误:

Chrome 37.0.2062 (Windows 8.1) ERROR Uncaught TypeError: Cannot read property 'clearTimeout' of undefined at [censored]/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 进行库存安装工作。

最佳答案

我现在感觉自己很没用。问题是由于在文件字段中重新加载 Jasmine 文件(除了框架之外)

解决方案是删除

    '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',

关于javascript - karma-jasmine 无法读取属性 'clearTimeout',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25871844/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com