为了账号安全,请及时绑定邮箱和手机立即绑定

jasmine:异步回调未在jasmine.DEFAULT_TIMEOUT_INTERVAL指定的超

jasmine:异步回调未在jasmine.DEFAULT_TIMEOUT_INTERVAL指定的超

我有一个叫的服务requestNotificationChannel:app.factory("requestNotificationChannel", function($rootScope) {    var _DELETE_MESSAGE_ = "_DELETE_MESSAGE_";    function deleteMessage(id, index) {        $rootScope.$broadcast(_DELETE_MESSAGE_, { id: id, index: index });    };    return {       deleteMessage: deleteMessage    };});我正在尝试使用茉莉花对该服务进行单元测试:"use strict";describe("Request Notification Channel", function() {    var requestNotificationChannel, rootScope, scope;    beforeEach(function(_requestNotificationChannel_) {        module("messageAppModule");        inject(function($injector, _requestNotificationChannel_) {            rootScope = $injector.get("$rootScope");            scope = rootScope.$new();            requestNotificationChannel = _requestNotificationChannel_;        })        spyOn(rootScope, '$broadcast');    });    it("should broadcast delete message notification", function(done) {        requestNotificationChannel.deleteMessage(1, 4);        expect(rootScope.$broadcast).toHaveBeenCalledWith("_DELETE_MESSAGE_", { id: 1, index: 4 });        done();           });});我阅读了有关Jasmine中的异步支持的信息,但是由于我对使用JavaScript进行单元测试相当陌生,因此无法使其正常工作。我收到一个错误:Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL而且我的测试执行时间太长(大约5秒)。有人可以帮助我提供一些可行的代码示例吗?
查看完整描述

3 回答

  • 3 回答
  • 0 关注
  • 1081 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信