ava
ava copied to clipboard
An option to disable enhanced assertion messages
The object can have a property with data\n x 1000.
https://pastebin.com/raw/3wg5nyab
I think a better solution is some kind of smart limits for the formatted. Maybe check out how Jest formats such a thing.
Friendly ping :)
Which assertions are you seeing this with?
deepEqual 100% and maybe is (don't remember but I think it would give that wall of text too).
It'd be useful to know how each assertion behaves. I must admit I've forgotten by now.
No worries :) I'll send a PR when I have more time.
I'm still seeing this and this is extremely annoying.
test.only('blah blah blah', t => {
const a = {};
const b = {};
for (let i = 0; i < 1000; i++) {
a[i] = Math.random();
b[i] = Math.random();
}
t.is(a, b); // t.deepEqual works too
});
test.only('blah blah blah 2', t => {
let string = '';
for (let i = 0; i < 2000; i++) {
string += 'data\n';
}
const a = {
string: ''
};
const b = {
string
};
t.is(a, b); // t.deepEqual works too
});
https://pastebin.com/raw/jWLk7NHR
Yes that's a lot of output!
Specifically in your case a lot of what's being shown is enumerable internals, but it's not really AVA's place to decide not to show enumerable properties.
What would you prefer here? I suppose we could stop printing the diff after N lines? But that would depend on whether we've shown any difference yet. Maybe it's OK as long as there's some sort of option to override. One might say --verbose but that currently changes a lot of reporter behavior.
This seems related to https://github.com/concordancejs/concordance/issues/12.
One solution would be to an add option to always truncate symbols like in the very end of the paste above:
...
+ [Symbol(local-settings)]: Object { … },
...
The other solution is almost the same you've proposed. Instead of stopping printing, just truncate the main object like in the example above if it's diff exceeds N lines.
This seems related to concordancejs/concordance#12.
It is, but in this example I don't care about the number of the properties. If it tells me that the exact 2 properties among the 1000 are different then I can easily perform debugging.
Instead of stopping printing, just truncate the main object like in the example above if it's diff exceeds N lines.
If this would be very CPU expensive and/or very slow, we can go with the number of properties. In that case, there should be an option to limit the depth.
I think https://github.com/concordancejs/concordance/issues/12 should "collapse" equal properties / items over a certain threshold.
Then in AVA, eventually, --verbose could undo that. But we could have some other flag or environment variable to disable the collapsing.
This really needs to be dealt with in Concordance first, though.
If this would be very CPU expensive and/or very slow, we can go with the number of properties. In that case, there should be an option to limit the depth.
Performance is less relevant for failing tests. Tests tend to pass.