Kent C. Dodds: 0:00 The last thing that we want to test here is calling run without a promise results in an early error. This one's going to be pretty simple. We experienced it already. All we're going to do here is get the results from calling render hook with useAsync. Then we can call result.current run with nothing, and we're going to get that error.
0:22 What we need to do is put this in an assertion, where we'll expect calling this function toThrow(), and that will pass. Let's make it a little bit more explicit. I'm a really big fan of using snapshots for error messages. We're going to say toThrowErrorMatchingInlineSnapshot(). We'll let just to stick the error message in there. Perfect.
0:45 If your hook is doing some runtime validation like this or throwing some sort of error, and you want to make an assertion on that, then you pass a function to expect. Expect will call that function around a try...catch, and then you can use toThrowErrorMatchingInlineSnapshot, and Jest will take a snapshot of that error message and stick it into your test code for you.
1:06 This makes it really easy to update the error message. If we wanted to, we just hit the U key, and it'll update our code for us automatically. I don't want to do that. We're going to save that. We'll hit the U key again, and there we go.