-
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
Magic assert #1155
Comments
I'm interested to see where this goes. I'm looking at the following error message right now thinking how it could be better.
So amen to magic assert! |
Using your current WIP branch:
Awww yeah! Thank you so much @vadimdemedes :) |
One thing to consider is the directionality of the
|
@ccorcos I agree, that it may be a little confusing. Are there any alternative "outputs" for diffs? I was following |
Would it be weird to use A for actual and E for expected? Array [
Object {
children: Array [
Object {
A type: "text",
A value: "[hello](world)",
E children: Array [
E Object {
E type: "text",
E value: "hello",
E },
E ],
E type: "link",
E url: "world",
},
],
type: "italic",
}, Probably looks a lot better with highlighting. |
On the subject of +/-/A/E perhaps there are suitable characters in Unicode? |
Array [
Object {
children: Array [
Object {
😕 type: "text",
😕 value: "[hello](world)",
💁 children: Array [
💁 Object {
💁 type: "text",
💁 value: "hello",
💁 },
💁 ],
💁 type: "link",
💁 url: "world",
},
],
type: "italic",
}, |
@thejameskyle I like your thinking. Array [
Object {
children: Array [
Object {
≠ type: "text",
≠ value: "[hello](world)",
☆ children: Array [
☆ Object {
☆ type: "text",
☆ value: "hello",
☆ },
☆ ],
☆ type: "link",
☆ url: "world",
},
],
type: "italic",
}, |
haha i like all of this |
I think we'll probably stick with the default "-" for "missing" and "+" for "extra" signs, like in |
AVA team is extremely excited to announce the new & shiny AVA feature. We call it "Magic assert".
We could try and describe
magic-assert
and all its features, but it's faster and better to let you see what it is all about right away.Strings
Different value types
Objects and arrays
t.true/t.false assertions
These kind of assertions obviously can't have diffs, because they're being compared to
true
/false
. Having "actual: true, expected: false" output wouldn't be much of a help, so instead we display the value of each statement in the assertion.Now that we got you all excited (hopefully), few words about what it actually is. Magic assert is not an assertion library, but a feature that handles assertion errors and is responsible for displaying them in a clean yet informative way. It replaces
power-assert
output, although it still uses its core for some cases.Magic assert adds code excerpts pointing to the source of the error and clean colorful diffs to each error report. You can also spot there's now more spacing between each error, which makes it easier to go through all the errors.
Your tests don't need to be modified in any way to take support
magic-assert
's output. If you use other assertion library like expect/chai or other, you are in luck too - you will get the same magical output!There's one more thing...
React support
Magic assert PR also lands two new assertion methods to improve React support:
t.jsxEquals()
andt.jsxNotEquals()
. And as you may have expected, it provides a nice output of the "React tree" as well!I'm not sure whether this change should be in this or separate PR - feedback welcome here too.
Credits
Magic assert was made possible by these amazing modules:
Huge thanks!
We think it is a big step forward towards more comfortable debugging of failed tests and developer happiness in general.
You can try Magic assert by using PR #1154 today!
We'd love to hear your feedback and ideas on how to improve the output of Magic assert! Thank you!
The text was updated successfully, but these errors were encountered: