-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Description
I'm having difficulties unit testing on state transition using Karma/Jasmine.
According to ui-router's own test/stateSpec.js, I might test state transition with something like the following:
it('should should transition to main.course', inject(function ($state, $q) {
$state.transitionTo('main.course');
$q.flush();
expect($state.current).toBe('main.course');
}));
However I'm getting an error:
TypeError: 'undefined' is not a function (evaluating '$q.flush()')
Can someone shed some light on this? I'd appreciate it. The error is very cryptic.
My full test is:
'use strict';
describe('Controller: CourseCtrl', function () {
// load the controller's module
beforeEach(module('myApp'));
var CourseCtrl, scope;
// Initialize the controller and a mock scope
beforeEach(inject(function ($controller, $rootScope) {
scope = $rootScope.$new();
CourseCtrl = $controller('CourseCtrl', {
$scope: scope
});
}));
it('should should transition to main.course', inject(function ($state, $q) {
$state.transitionTo('main.course');
$q.flush();
}));
});
I've recreated a very minimal application that tests this here.
Metadata
Metadata
Assignees
Labels
No labels