-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix(ngMock): Change ErrorAddingDeclarationLocationStack prototype #14344
fix(ngMock): Change ErrorAddingDeclarationLocationStack prototype #14344
Conversation
change prototype to Error.prototype so test frameworks can catch it properly angular#13821
adding test to verify change
removed trailing whitespace, fixed 4-space tab, changed to 2 spaces
Fix for issue #13821 |
}); | ||
} | ||
|
||
//The following is a simplified implementation of future Jasmine's .toThrowError() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by future Jasmine's .toThrowError()
?
Why can't you use it directly ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
toThrowError()
was introduced in Jasmine 2.0. It uses errorObject instanceof Error
to check if the thrown object is an Error Object (for matching strings/regex against their .message
property). Angular's build environment uses now >2-year-old Jasmine 1.3 for its own tests, so I had to rig a basic function for how Jasmine's toThrowError()
fails when running this code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not any more :) We are on Jasmine 2 now 😎
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoo! Let me amend this PR in the coming days
@peabnuts123 Did you ever get around to updating this PR? |
Unfortunately I've been pretty busy and have been unable to update this. I still intend to, as this fix is something I need in my project. Currently just using my own fork in our build... |
I've changed the unit test to utilise the real Jasmine The Travis build appears to have failed unrelated to anything I've changed? Can this be confirmed / re-run? |
Travis is green now 👍 |
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
fix to angular-mocks for ErrorAddingDeclarationLocationStack error to change its prototype to Error.prototype
What is the current behavior? (You can also link to an open issue here)
Testing frameworks and other libraries interacting with angular cannot correctly detect this error with
instanceof
What is the new behavior (if this is a feature change)?
This Error is correctly inherited from
Error
.ErrorAddingDeclarationLocationStack instanceof Error === true
.Does this PR introduce a breaking change?
No, in fact it only changes one line.
Please check if the PR fulfills these requirements
Other information:
Apologies for ridiculous branch name. I hope this was all done correctly, I am still new to git/GitHub
change prototype to Error.prototype so test frameworks can catch it properly
#13821