javascript - Jasmine 与 karma : Cannot find variable runs

标签 javascript angularjs testing jasmine karma-runner

我需要一个插件/lib 来使用 Jasmine 的 runs() 和 waits() 吗?我正在查看异步测试的 Jasmine 维基页面:https://github.com/pivotal/jasmine/wiki/Asynchronous-specs .

他们没有提到需要特殊的库/插件,所以我认为 runs() 和 waits() 应该开箱即用。

我的代码看起来像这样(它包含在描述中):

it('test', function() {
    runs(function() {

    });
});

我得到:ReferenceError: runs is not defined

我的 karma 配置的相关部分是:

    files: [
        'bower_components/jquery/dist/jquery.min.js',
        'bower_components/angular/angular.js',
        'bower_components/angular-mocks/angular-mocks.js',
        'src/*.js',
        'test/*.spec.js'
    ],


    frameworks: ['jasmine'],

    browsers: ['PhantomJS'],

    plugins: [
        'karma-spec-reporter',
        'karma-chrome-launcher',
        'karma-firefox-launcher',
        'karma-jasmine',
        'karma-phantomjs-launcher'
    ],

最佳答案

好的,原来 Jasmine 2.0 已经删除了 runs()waits()waitsFor()。新的异步支持使用 done(),可在以下位置找到:http://jasmine.github.io/2.0/introduction.html#section-Asynchronous_Support .我已经在过时的 github wiki 页面上添加了关于此的快速注释。

关于javascript - Jasmine 与 karma : Cannot find variable runs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22493163/

相关文章:

javascript - 为什么这里需要 $scope.$apply() 来进行简单的删除,推荐的方法是什么(因为使用它,它会引发错误)?

javascript - AngularJS数据推送

javascript - 检测 TAB 按键并使脚本执行有条件

javascript - 警报中的重音字母格式不正确?

c# - 在后台任务中运行 WebView

reactjs - 创建快照时 Jest/Enzyme ShallowWrapper 为空

java - 异步 API 性能更差

c# - 如何在慢速互联网连接上测试程序?

javascript - Select2 - 通过 ajax 调用传回附加数据

javascript - meteor .js : how to pass the data context of one helper to another helper?