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

fix(ngMock): don't clean up if currentSpec is null.#16856

Open
heathkit wants to merge1 commit intoangular:v1.6.x
base:v1.6.x
Choose a base branch
Loading
fromheathkit:v1.6.x

Conversation

heathkit
Copy link

@heathkitheathkit commentedMar 22, 2019
edited
Loading

In unit tests that use Angular and AngularJS, sometimes an error being thrown during the test and cause this afterEach hook to run twice. If that happens, on the second run cleanup will throw an error, since at that point currentSpec is null. This causes the original error to be hidden by a "TypeError: Cannot read property '$injector' of null while testing" error.

This makes cleanup safe to call multiple times, working around the issue.

This fix is needed to resolve an internal issue affecting Angular unit tests. I discussed this with Igor, and he asked me to submit this as a PR. No release is necessary, we just need this in google3.

@heathkitheathkit changed the titlefix(ngMocks): Don't clean up if currentSpec is null.fix(ngMock): Don't clean up if currentSpec is null.Mar 22, 2019
@heathkitheathkitforce-pushed thev1.6.x branch 2 times, most recently from91a91b6 to79b8317CompareMarch 22, 2019 04:15
@heathkitheathkit changed the titlefix(ngMock): Don't clean up if currentSpec is null.fix(ngMock): don't clean up if currentSpec is null.Mar 22, 2019
@gkalpak
Copy link
Member

I would feel better if we understood why this happens. Why is theafterEach() block run twice?

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 behidden by a "TypeError: Cannot read property '$injector' of null whiletesting" error.This makes cleanup safe to call multiple times, working around theissue.
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers
No reviews
Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@heathkit@gkalpak@googlebot

[8]ページ先頭

©2009-2025 Movatter.jp