| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
I would feel better if we understood why this happens. Why is the afterEach() block run twice? |
Sorry, something went wrong.
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.
| Back | FazBrowse Home | New Git URL |
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.