Karma测试:PhantomJS:ReferenceError:找不到变量:Pusher

时间:2015-05-11 21:17:07

标签: javascript angularjs unit-testing phantomjs

我正在编写一些单元测试,在我的AngularJS控制器中,我正在使用Pusher进行异步连接。

  var DriverCtrl,
    scope;

  var $httpBackend = {};

  beforeEach(inject(function ($controller, $rootScope, _$httpBackend_, _DriverService_, _PusherService_, _AuthService_) {
    scope = $rootScope.$new();
    DriverCtrl = $controller('DriverCtrl', {
      $scope: scope,
      DriverService: _DriverService_,
      PusherService: _PusherService_,
      AuthService: _AuthService_
    });
    $httpBackend = _$httpBackend_;
  }));

  afterEach(function () {
    $httpBackend.verifyNoOutstandingExpectation();
    $httpBackend.verifyNoOutstandingRequest();
  }); 

首先我通过推文文档后得到了异常,我对karma.conf.js和bower.json进行了更改

 PhantomJS 1.9.8 (Linux) DriverCtrl should be connected to driver view FAILED
            ReferenceError: Can't find variable: Pusher

karma.conf.js,我添加了这一行

'bower_components/angular-scenario/angular-scenario.js'

和bower.json。我是这一节

"devDependencies": {
    "angular-mocks": "~1.2.0",
    "angular-scenario": "~1.2.0",
    "pusher-test-stub": "*"
  }

现在我收到了以下错误

WARN [watcher]: Pattern "/home/machine/RubyProjects/TaxiTeam4/taxihome-frontend/test/mock/**/*.js" does not match any file.
INFO [PhantomJS 1.9.8 (Linux)]: Connected on socket imIXyLQV7jW3QeXo0W5c with id 33183997
PhantomJS 1.9.8 (Linux): Executed 0 of 0 ERROR (0.001 secs / 0 secs)
Warning: Task "karma:unit" failed. Use --force to continue.

我试过更改karma.conf.js中的端口没有帮助

0 个答案:

没有答案