-
Notifications
You must be signed in to change notification settings - Fork 27.4k
ngMock: ErrorAddingDeclarationLocationStack is no longer matched by toThrowError since jasmine 2.4.1 #13821
Comments
ngMock has been built with the now ancient jasmine 1.3 in mind (core tests are based on 1.3). I think if we can support this change without breaking any existing tests, we can change it in ngMock, otherwise you cannot use ngMock with jasmine 2.4.1 (or this specific function) |
Why don't we simply do |
@Narretz oh my ;) @gkalpak That's what I think may be dangerous for some reason. |
Interesting: I tried to replicate the issue with Jasmine 2.4.1, but everything seems to work as expected. |
@gkalpak the problem may be that Jasmine finds no specs in your pen: "No specs found" I don't have experience in running jasmine out of karma therefore I don't see the reason this is like that right away. Please check if test code runs. --- EDIT--- ---- EDIT2--- |
Yeah, I wasn't using arrow functions at first, then changed to arrow functions as in your example to see if they have something to do with it. (I updated the pen.) |
I tried but I wasn't able to do it. I'm running tests using a gulp plugin on Phantom. AFAIK it shouldn't matter, but some part of this setup matters |
+1 can confirm my environment is producing exactly the same results
EDIT: I have modified @gkalpak's pen to produce the error with minimal code here. |
@peabnuts123: Thx for the reproduction. @jrencz: I don't think there is any "danger" in changing @jrencz or @peabnuts123: If anyone fancies submitting a PR, that would be awesome 😃 |
change prototype to Error.prototype so test frameworks can catch it properly angular#13821
I have put together a pull request to change the prototype of |
Environment:
I try to match error thrown in my code:
with the following test:
but I get error in the console:
this is error from [email protected] toThrowError matcher.
Jasmine stopped comparing by
constructor
in favour of usinginstanceof
operator in April 2015The problem is caused by 7e916455b3
I tried modifying:
which was ok when
constructor
was checked in a way thatErrorAddingDeclarationLocationStack
hasError
in its prototype chain:and I can confirm it fixes the issue (error is considered an actual error again by [email protected])
@wizardwerdna can you please review this change? I'm not sure if you replaced only
toString
on a prototype for a reason and if it's safe to do what I suggest. I think it may not be safe to do so and this change can reverse what you achieved. In such case a better way has to be found to circumnavigate the issue you fixed in order to be able to keep using [email protected] with ngMock.The text was updated successfully, but these errors were encountered: