【问题标题】:karma-jasmine Cannot read property 'clearTimeout'业力茉莉无法读取属性“clearTimeout”
【发布时间】: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


    【解决方案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',
    

    【讨论】:

    • 谢谢你,我也做了同样的事……我也觉得没用:)
    猜你喜欢
    • 2021-09-28
    • 2019-04-06
    • 1970-01-01
    • 2021-08-05
    • 2014-12-12
    • 2013-11-14
    • 2018-12-08
    • 2017-01-15
    • 1970-01-01
    相关资源
    最近更新 更多