Const
expect.anything() matches everything except null and undefined. Use it inside expect(value).toEqual(expected) to perform pattern matching.
expect.anything()
null
undefined
Usage
const value = { prop: 1 };expect(value).toEqual({ prop: expect.anything() });expect(value).not.toEqual({ otherProp: expect.anything() }); Copy
const value = { prop: 1 };expect(value).toEqual({ prop: expect.anything() });expect(value).not.toEqual({ otherProp: expect.anything() });
expect.anything()matches everything exceptnullandundefined. Use it inside expect(value).toEqual(expected) to perform pattern matching.Usage