-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
assert.deepEqual assertion error depth limit #15696
Comments
I think there needs a different shape of AssertionError for deepEqual, maybe replacing original and expected by a string showing either:
in both case, it could be worth to represent (possibly deep) object paths maybe like: - foo.bar.qux.lolcat.bip.yup: 56
+ foo.bar.qux.lolcat.bip.yup: 56.3 or - foo: {bar: {qux: {lolcat: {bip: {yup: 56
+ foo: {bar: {qux: {lolcat: {bip: {yup: 56.3 What are the thoughts? I'll be glad to try to implement it |
Not really object to this idea, but there is already power-assert that basically does the same thing (with very fancy diffs) |
I checked power-assert, it's fancy, but I think a simple approach can be worth for this specific case of object compaisons (not expressions, ...) deepEqual({
foo: {
bar: {
qux: {
lolcat: {
bip: {
yup: 56.3
}
},
mlop: {}
}
}
}
}, {
foo: {
bar: {
qux: {
lolcat: {
bip: {
yup: 56
}
},
mlep: {
cool: 'tes',
flip: 878.964
}
}
}
}
})
|
I made this: https://github.com/caub/deep-eq. Power-assert is cool indeed, but requires transpiling, etc.. I'd still like possibly to change node's assert deepEqual, because it's there by default, and it's really not practical |
Note: Node.js |
I think it would be better if the message of
assert.deepEqual
was not limited to a depth of 3, and could display the first difference between the objects, like some testing libraries doA simple implementation example:
The current implementation passes the entire objects in the Error, and .toString is limited in 3 in depth I guess
The text was updated successfully, but these errors were encountered: