Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 898714d

Browse files
committedFeb 6, 2015
fix(ngMock): handle cases where injector is created before tests
This caused an exception for people who created an injector before the tests actually began to run. Since the array was initialized only in beforeEach, anyone accessing it before that would throw. This is solved easily but initializing the array immediately. Closes #10967
1 parent 966f6d8 commit 898714d

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed
 

Diff for: ‎src/ngMock/angular-mocks.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2131,7 +2131,7 @@ angular.mock.$RootScopeDecorator = ['$delegate', function($delegate) {
21312131
if (window.jasmine || window.mocha) {
21322132

21332133
var currentSpec = null,
2134-
annotatedFunctions,
2134+
annotatedFunctions = [],
21352135
isSpecRunning = function() {
21362136
return !!currentSpec;
21372137
};

Diff for: ‎test/ngMock/angular-mocksSpec.js

+7
Original file line numberDiff line numberDiff line change
@@ -1813,3 +1813,10 @@ describe('ngMockE2E', function() {
18131813
});
18141814
});
18151815
});
1816+
1817+
describe('make sure that we can create an injector outside of tests', function() {
1818+
//since some libraries create custom injectors outside of tests,
1819+
//we want to make sure that this is not breaking the internals of
1820+
//how we manage annotated function cleanup during tests. See #10967
1821+
angular.injector([function($injector) {}]);
1822+
});

0 commit comments

Comments
 (0)