Friday, 17 January 2020

Expect a function to throw an exception in Jest

I have a function (hostelService.book) that returns a promise: return Promise.resolve(response); and I made this test:

const action = async () => {
        await hostelService.book(id);
    };


  await expect(action).rejects.toThrow();

but I have this error:

 Matcher error: received value must be a promise


from Expect a function to throw an exception in Jest

No comments:

Post a Comment