In this example:
Nick Carter
11

Since Jest 20.0.0 you can also do this with async functions, which I find much more neat:

await expect(drive.load()).rejects.toBeDefined();

If you want to get fancy you can even go for matching the error message:

await expect(drive.load()).rejects.toMatchObject({
message: '...'
});

So I am starting to use this instead of my custom function; it’s more standard and it’s being improved as we speak.

Like what you read? Give Francisco Presencia a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.