We recently upgraded the angular version from 1.6 to 1.8. And a few of our test cases started to fail. Here is one of the samples. In the below code, Within the 'it' block, the 'element' becomes 'undefined'. Can you help me with what went wrong?
(function( angular ) {
'use strict';
describe('Describe Main', function () {
var element, $scope, $rootScope, $timeout, $window;
beforeEach( function() {
$window = {
history: {
replaceState: jasmine.createSpy( '$window.history.replaceState' )
},
location: {
replace: jasmine.createSpy( '$window.location.replace' )
}
};
module( 'ModuleSearch', function( $provide ) {
$provide.value( '$window', $window );
$provide.value( '$document', [{}] );
} );
} );
describe( 'Directive inside', function() {
beforeEach( inject( function( _$rootScope_, $compile, _$timeout_ ) {
element = angular.element( '<div component-tabs on-change="changeTab(newTab)"></div>' );
$rootScope = _$rootScope_;
$timeout = _$timeout_;
$rootScope.changeTab = jasmine.createSpy( 'changeTab' );
$rootScope.currentMailbox = 'test';
$compile( element )( $rootScope );
$rootScope.$digest();
$scope = element.isolateScope();
} ) );
it( 'should set text as default', function() {
expect( element.find( 'li' ).eq( 0 ).hasClass( 'active' ) ).toBeFalsy();
} );
});
});