首页 文章

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

提问于
浏览
0

我似乎无法工作 karma-jasmine .

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

Chrome 37.0.2062(Windows 8.1)错误未捕获TypeError:无法读取[censored] /node_modules/karma-jasmine/lib/jasmine.js:1826中未定义的属性'clearTimeout'

这是我用 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进行库存安装工作 .

1 回答

  • 1

    我现在觉得很无用 . 问题是由于重新加载文件字段中的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',
    

相关问题