I'd like to have this in core lib
https://github.com/Dean177/jest-to-match-shape-of
When you have an object which has timestamp inside e.g.:
{
name : 'Foo',
surname: 'Bar',
createdAt: 1507797749, <-- unix timestmap or other date format
}
https://facebook.github.io/jest/docs/en/expect.html#tomatchobjectobject will fail always while date value is moving. Would be great to have toMatchObjectShape. And it should go into child objects too.
Now I have to go around such cases by resetting result object (got from e.g. API endpoint) + I have to write expect cases for all time-based fields individually to check if a value was there before the reset.
Jest is great, I love it. Thanks for all who contribute 馃憤
expect(someObj).toEqual(expect.objectContaining({
name: 'foo',
surname: 'bar',
createdAt: expect.any(Number),
}));
or
expect(someObj).toEqual({
name: 'foo',
surname: 'bar',
createdAt: expect.any(Number),
});
(written by hand, take with a small grain of salt)
http://facebook.github.io/jest/docs/en/expect.html#expectobjectcontainingobject
Most helpful comment
or
(written by hand, take with a small grain of salt)
http://facebook.github.io/jest/docs/en/expect.html#expectobjectcontainingobject