Matches anything that was created with the given constructor. You can use it inside toEqual
or toBeCalledWith
instead of a literal value.
Symbol
AsymmetricMatchers.any
function randocall(fn) {
return fn(Math.floor(Math.random() * 6 + 1));
}
test('randocall calls its callback with a number', () => {
const mock = jest.fn();
randocall(mock);
expect(mock).toBeCalledWith(expect.any(Number));
});