expect.any() matches any object instance created from the
constructor
or a corresponding primitive type. Use it inside
expect(value).toEqual(expected)
to perform pattern matching.
Usage
// Match instance of a class. classExample {} expect(newExample()).toEqual(expect.any(Example));
// Match any number. expect({ prop:1 }).toEqual({ prop:expect.any(Number) });
// Match any string. expect('abc').toEqual(expect.any(String));
Param: constructor
Constructor of the expected object like ExampleClass, or a primitive boxed type like Number.
expect.any()matches any object instance created from theconstructoror a corresponding primitive type. Use it inside expect(value).toEqual(expected) to perform pattern matching.Usage