Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
/angular.jsPublic archive

Commitc06a25e

Browse files
committed
fix(ngMocks): Don't clean up if currentSpec is null.
In unit tests that use Angular and AngularJS, sometimes an error beingthrown during the test and cause this afterEach hook to run twice. Ifthat happens, on the second run cleanup will throw an error, since atthat point currentSpec is null. This causes the original error to behiden by a "TypeError: Cannot read property '$injector' of null whiletesting" error.This makes cleanup safe to call multiple times, working around theissue.
1 parent33b5c50 commitc06a25e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

‎src/ngMock/angular-mocks.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3000,6 +3000,9 @@ angular.mock.$RootScopeDecorator = ['$delegate', function($delegate) {
30003000
};
30013001

30023002
module.$$cleanup=function(){
3003+
if(!currentSpec){
3004+
return;
3005+
}
30033006
varinjector=currentSpec.$injector;
30043007

30053008
annotatedFunctions.forEach(function(fn){

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp