jeudi 2 juillet 2015

Jasmine test for Angular directive not working

I'm attempting to run a very basic test of an Angular directive, but cannot seem to get it to run. My code is below. The error I'm seeing from jshint is: 'inject' is not defined, and the error for my failed test is: TypeError: object is not a function.

'use strict';

describe('playerInfo directive', function() {
  var $compile;
  var $rootScope;

  beforeEach(module('gameApp'));

  beforeEach(inject(function(_$compile_, _$rootScope_) {
    $compile = _$compile_;
    $rootScope = _$rootScope_;
  }));

  it('should replace the element with the appropriate content', function() {
    var element = $compile('<dm-player-info></dm-player-info>')($rootScope);
    $rootScope.$digest();
    expect(element.html()).toContain('Member Since:');
  });
});

Aucun commentaire:

Enregistrer un commentaire