Jest: toMatchObject

Created on 8 Dec 2016  路  8Comments  路  Source: facebook/jest

  1. The documentation for .toMatchObject in the API reference is missing ')' and if cut and paste into a node session gets syntax errors because of two cases of no closing ')'.

describe('looking for a new house', () => { it('the house has my desired features', () => { expect(houseForSale).toMatchObject(desiredHouse); } }

  1. After fixing the code running the sample results in

TypeError: expect(...).toMatchObject is not a function

this is with node v7.2.0

Most helpful comment

Please upgrade to Jest 18.

All 8 comments

This is a duplicate of #2195 and it got me too a few days ago. Coming soon :)

The missing parens have been corrected on master in https://github.com/facebook/jest/commit/97a3ab6544a666c30418b86b9fc2ba14aa202b41

Thanks @pedrottimark for pointing to the duplicate!

@talkingtab you'll need to wait a little for the next release to use toMatchObject().
You can read about the reasons in the issue mentioned above.
Closing.

Is the "next release" available? I saw another thread implying that it's available by now, but I did an update and still get the error.

Release is scheduled for Thursday (tomorrow), so stay tuned!

Guys, happy new year, still can't use toMatchObject() :/

Please upgrade to Jest 18.

Guys, but I think a good idea would be to add require Jest 18+ to Asymmetric Jest Matchers section in the docs, I spent like 1 hour trying to make it work.

yes, we'll do this going forward.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stephenlautier picture stephenlautier  路  3Comments

paularmstrong picture paularmstrong  路  3Comments

jardakotesovec picture jardakotesovec  路  3Comments

gustavjf picture gustavjf  路  3Comments

ianp picture ianp  路  3Comments