This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Commit 21885b2
committed
fix(ngMock window.inject): fix collecting stack trace in PhantomJS
Add support for collecting current stack trace information in browsers
(e.g. PhantomJS) that do not automatically store the current stack trace
information in a newly created `Error` object's `stack` property, but
only add it there once the `Error` gets thrown.
The original implementation works fine in Firefox & Chrome, but fails on
PhantomJS where it, for example, breaks karma's error reporting in cases
when an exception for thrown in a test like the following:
```
it('the holy crusade', inject(function () {
var x = {};
x.holyGrail();
}));
```
where the ngMock `inject()` implementation would incorrectly add the word
`undefined` to the end of the collected error stack trace information,
thus causing the main error description to be reported back to karma as
`undefined`.
The whole `Error.stack` property and its behaviour is not standardized so
there is no one true implementation that we can assume is used by all
angular compatible browsers.
MSDN JavaScript `stack Property (Error) (JavaScript)` docs found at
http://msdn.microsoft.com/en-us/library/windows/apps/hh699850.aspx also
seem to match the PhantomJS implementation.1 parent 0cbe7fb commit 21885b2
1 file changed
+9
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2899 | 2899 | | |
2900 | 2900 | | |
2901 | 2901 | | |
| 2902 | + | |
| 2903 | + | |
| 2904 | + | |
| 2905 | + | |
| 2906 | + | |
| 2907 | + | |
| 2908 | + | |
| 2909 | + | |
| 2910 | + | |
2902 | 2911 | | |
2903 | 2912 | | |
2904 | 2913 | | |
| |||
0 commit comments