-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include raw actual and expected objects in AssertionError #1432
Include raw actual and expected objects in AssertionError #1432
Conversation
How does Wallaby access these properties? |
@novemberborn Wallaby doesn't use AVA process. We create an instance of the |
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.
Wallaby doesn't use AVA process. We create an instance of the ava/lib/runner class and use it to run tests in our own process(es).
Aha! This should be fine then.
Let's store the values in a AssertionError#raw
property (and pass a raw
argument to the constructor). It'd help if you could add a code comment saying Wallaby uses this value since it manages AVA worker processes directly, lest we forget and remove it due to being unused.
…operty and pass a raw argument to the constructor
@novemberborn Great, thanks. Made the requested changes and left the comment (new tests should also help not to remove the property accidentally). |
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.
new tests should also help not to remove the property accidentally
You'd be surprised what I remove, especially if AVA itself doesn't use it 😉
As you're probably aware Wallaby is using internal APIs here. There isn't much overhead in tracking these values so we're happy to help, but it all might still break in the next release.
lib/assert.js
Outdated
@@ -29,7 +29,7 @@ function formatWithLabel(label, value) { | |||
} | |||
|
|||
class AssertionError extends Error { | |||
constructor(opts) { | |||
constructor(opts, raw) { |
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.
Apologies, I meant passing raw
as a property in opts
.
@novemberborn Fair enough, thanks for your help! Yep, we are aware that we are using AVA's internal APIs and things get broken sometimes, but thankfully our AVA users report them fairly quickly. Made the requested change. |
Thanks @ArtemGovorov! |
This is useful for tools, such as wallaby.js, that bind to AVA's private APIs for tighter integration.
We support AVA in wallaby.js and have a few custom renderers for displaying assertions diffs in various editors, like:
VS Code:
WebStorm:
Wallaby App:
Other testing frameworks that we support (also various assertion libs, such as
chai
) pass rawactual
andexpected
objects with their assertion errors, so we (and other custom reporters) are able to display custom diffs.AVA's new coloured ANSI diff display is great, but in order to display diffs outside of the ANSI supporting viewer (such as in the cases listed above), it would be great if the
AssertionError
contained rawactual
andexpected
objects, so that a customer reporter integrated with AVA could use them for doing custom diffs/reporting (the screenshots above show how it'd look like once the PR is landed and published in AVA).The pull request implements passing the raw
actual
andexpected
objects to theAssertionError
constructor.