jest to throw with message code example
Example 1: jest expect error to be thrown
test("Test description", () => {
const t = () => {
throw new TypeError();
};
expect(t).toThrow(TypeError);
});
Example 2: expect any function jest
expect(something).toEqual(expect.any(Function))