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

ospec does not print objects deeply #1661

Closed
IBwWG opened this Issue Feb 25, 2017 · 6 comments

Comments

Projects
None yet
4 participants
@IBwWG
Copy link

IBwWG commented Feb 25, 2017

Mithril 1.0.1, trying to use deepEquals:

        o({ a: 1, b: 2 }).deepEquals({ a: 1, b: 1});

...results in:

[object Object]
should deep equal
[object Object]

Maybe that's expected by some, but I think deep-printing the objects (or better yet, just where their first difference occurs) would be helpful.

@isiahmeadows

This comment has been minimized.

Copy link
Collaborator

isiahmeadows commented Feb 25, 2017

Maybe using util.inspect would help here. Just a thought.

@pygy

This comment has been minimized.

Copy link
Member

pygy commented Feb 25, 2017

And fall back to console.log for browsers?

@isiahmeadows

This comment has been minimized.

Copy link
Collaborator

isiahmeadows commented Feb 25, 2017

@pygy

This comment has been minimized.

Copy link
Member

pygy commented Feb 25, 2017

Oh, yes, my bad, it's a formatter...

@isiahmeadows isiahmeadows changed the title ospec deepEquals output is not deep ospec does not print objects deeply Feb 26, 2017

@isiahmeadows isiahmeadows added the bug label Feb 26, 2017

@IBwWG

This comment has been minimized.

Copy link

IBwWG commented Feb 27, 2017

Would it be as easy as just chopping the middle out of https://github.com/lhorie/mithril.js/blob/next/ospec/ospec.js#L206 so objects fall through the if chain and get JSON.stringify()'d?

@levicook

This comment has been minimized.

Copy link

levicook commented Apr 23, 2017

+1 on falling through to JSON.stringify.

Current work around on my team, is to wrap simple objects in an array. eg:
o({ a: 1, b: 2 }).deepEquals({ a: 1, b: 1}); becomes:
o([{ a: 1, b: 2 }]).deepEquals([{ a: 1, b: 1}]);

Obviously hacky, but helpful because it beats [object Object]

isiahmeadows pushed a commit that referenced this issue Sep 3, 2017

Isiah Meadows
Merge pull request #1955 from porsager/next
Use util.inspect to log in node - fixes #1661
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment