Skip to content
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

An option to disable enhanced assertion messages #2289

Closed
szmarczak opened this issue Nov 5, 2019 · 14 comments
Closed

An option to disable enhanced assertion messages #2289

szmarczak opened this issue Nov 5, 2019 · 14 comments

Comments

@szmarczak
Copy link

The object can have a property with data\n x 1000.

@szmarczak
Copy link
Author

@sindresorhus
Copy link
Member

I think a better solution is some kind of smart limits for the formatted. Maybe check out how Jest formats such a thing.

@szmarczak
Copy link
Author

Friendly ping :)

@novemberborn
Copy link
Member

Which assertions are you seeing this with?

@szmarczak
Copy link
Author

deepEqual 100% and maybe is (don't remember but I think it would give that wall of text too).

@novemberborn
Copy link
Member

It'd be useful to know how each assertion behaves. I must admit I've forgotten by now.

@szmarczak
Copy link
Author

No worries :) I'll send a PR when I have more time.

@szmarczak
Copy link
Author

szmarczak commented Jul 9, 2020

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
});

@szmarczak
Copy link
Author

@novemberborn
Copy link
Member

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 concordancejs/concordance#12.

@novemberborn novemberborn reopened this Jul 12, 2020
@szmarczak
Copy link
Author

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.

@szmarczak
Copy link
Author

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.

@szmarczak
Copy link
Author

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.

@novemberborn
Copy link
Member

I think concordancejs/concordance#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.

@novemberborn novemberborn closed this as not planned Won't fix, can't repro, duplicate, stale Jul 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants