Jest Expect Object Containing
I used to do this a lot:
const { somethingIDontCareAbout, ...everthingIDoCareAbout } = stuff
expect(everythingIDoCareAbout).toEqual(expectedStuff)
Now I learned about objectContaining
and I can do this instead:
expect(stuff).toEqual(expect.objectContaining(expectedStuff))
H/T Dillon Hafer
Tweet