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

toBeObject matches also array #148

Closed
cs4inctec opened this issue Jul 12, 2018 · 4 comments
Closed

toBeObject matches also array #148

cs4inctec opened this issue Jul 12, 2018 · 4 comments

Comments

@cs4inctec
Copy link

Bug

  • package version: 0.7.2
  • node version: 8.11.2
  • npm version: 5.6.0

Relevant code or config

test('should not match', () => {
    expect([1, 2, 3, 4]).toBeObject();
})

What you did:
I tested if an element is an object and printed it to screen.

What happened (please provide anything you think will help):
Output was an array, but the test did not fail.
I expected that an array would fail on toBeObject.

@benjaminkay93
Copy link
Contributor

I ran this myself, it also passes on node 10.5 with npm 6.1, I don't think this is expected behaviour

@mattphillips
Copy link
Member

Hey @cs4inctec thanks for reporting this, seems like a bug to me!

@andrew-yustyk
Copy link

Seems like the quickest solution is to add !Array.isArray(expected) condition to the toBeObject matcher

@mattphillips
Copy link
Member

Fixed in 230d071

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

4 participants