Thanks to visit codestin.com
Credit goes to github.com

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

Commit 39ddef6

Browse files
committed
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 11aedbd commit 39ddef6

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/ngMock/angular-mocks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2127,7 +2127,7 @@ angular.mock.$RootScopeDecorator = ['$delegate', function($delegate) {
21272127
if (window.jasmine || window.mocha) {
21282128

21292129
var currentSpec = null,
2130-
annotatedFunctions,
2130+
annotatedFunctions = [],
21312131
isSpecRunning = function() {
21322132
return !!currentSpec;
21332133
};

test/ngMock/angular-mocksSpec.js

Lines changed: 7 additions & 0 deletions
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)