-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
jest-each does not serialize values properly #6321
Comments
Have you tried |
@aaronabramov @SimenB I was looking into this during the summit, I’ve got some code stashed locally to try to improve the behaviour. @SimenB perhaps vsprintf does offer slightly better serialisation than Nodes util format? |
since the nature of this feature is feeding a bunch of different values into test, i don't think what if we just use generic placeholders like:
also we can't serialize two values into the same string, because it'll result in two tests with the same name/id and their snapshots names will conflict. for example this will have a lot of strings that are the same, but their values are different: const a = {x: 1};
const b = {x: 1};
test.each([
[a, {x: 1}],
[b, {x: 1}],
[a, b],
[{o: a}, {o: b}]
[{o: a}, {o: a}]
])('{} is not {}', (v1, v2) => {
expect(v1 === v2).toBeFalse();
}); should we do something like:
if they serialize into the same string? |
when i was writing tests for i think it'd be super nice if |
Good point. I'd be down with |
|
I see this as being two separate issues:
I'd be hesitant to add generic placeholders as We could do I think I'd be open to maybe adding support to @aaronabramov for your example you could use
This seems like a valid problem with a normal |
i think |
There's a lint rule in the plugin for duplicate test names. Should probably expand it to support yelling at dupes resulting from |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
i was trying to migrate some of our tests to use
jest-each
, but for a lot of cases it won't work because of serialization thatjest-each
uses:is it possible to use
pretty-format
for this serialization? (but collapsing everything in one line)The text was updated successfully, but these errors were encountered: