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

Fix ngMock window.inject() error stack trace reporting on repeated or non-initial injection function calls for the 1.4.x branch (issue #13594) #13597

Open
wants to merge 7 commits into
base: v1.4.x
Choose a base branch
from

Conversation

jurko-gospodnetic
Copy link
Contributor

Fixes & adds tests for issue #13594 for the angular 1.4.x branch.

Does the same work as pull request #13598 does on the angular master branch.

window.inject() function updates stack trace information for Error objects thrown from injection functions passed to it with stack trace for the window.inject() calling location. However this functionality was broken and did not work correctly in the following cases:

  • when the same injection function gets called multiple times
  • when more than one injection function is passed to a single window.inject() call and a non-initial one throws an Error

This pull request actually builds on and thus includes pull request #13592, as newly added test specs are integrated into the test structure set up by the base pull request. That's why you should first review & merge that pull request, or ignore its commits when reviewing this one.

Split up `ngMock` `window.inject` tests into tests on browsers supporting
fetching current stack trace information and those not supporting it, as
we plan on adding new test specs to the first group.

Required making the test inject caller function more flexible so it can be
easily configured in different tests without unnecessary code duplication.
…ment

The results of this function, when called outside of a specific test spec
context, should not be reused in multiple tests as they may have stored
state that can cause unwanted test spec interaction. This explains why we
may need to wrap some tests into their own separate test suites instead
of grouping them all under a single shared one.
…apper usage

Explicitly commented on why we use an extra function wrapper around the
test inject Error throwing code, and how not using it would make our
tests give us false positives on certain browsers, e.g. Firefox.
…vocations

Failed injection functions should consistently include their respective
window.inject() call location information in their stack trace, even on
repeated invocations & when they have been passed as a non-initial
parameter to their window.inject() call.
…alls

Injection function throwing an Error should update the thrown Error's
stack trace information with the window.inject() call location information,
on its initial as well as repeated invocations.
… functions

Injection function throwing an Error should update the thrown Error's
stack trace information with the window.inject() call location information
even when multiple injection functions are passed to the window.inject()
call and non-initial provided function fails.

Closes angular#13594.
@jurko-gospodnetic jurko-gospodnetic force-pushed the ngMock-inject-stack-trace-on-multiple-calls-for-1.4.x branch from e0aafea to e1e3274 Compare April 11, 2016 06:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants