Loading
Current section: Custom Assertions 3 exercises
Problem

Custom Matchers for Assertions

Loading exercise

Transcript

00:00 You know these assertions that we've got down here where we have assertToSent and sessionMade and assertRedirect, they don't really match the style of the expect assertion library, and you can actually make your own matchers. In fact, we're using some of those in our,

00:16 let's see, double check test right here. So we've got some custom matchers right here to have text content. That's a custom matcher that comes from just DOM. So we can make our own custom matchers for our own application that are very specific to our use cases. So like assertRedirect, that definitely could be a custom matcher.

00:36 In fact, all of these could be a custom matcher that we can make ourselves. So your task is to make a custom matcher just for the assertRedirect assertion, and then update all the places where we're using assertRedirect to be expect response to have the redirect.

00:55 Once you do that, then the code will read a lot nicer, and even errors will look a lot nicer as well. So give that a shot. It is a little bit complicated. It might take you a little bit to figure out the special syntax, especially since there's also the negation.

01:12 So all of these can have a not and do the opposite. So it is a little bit funny, but spend some time, definitely look at the docs and stuff, and I think that you'll be successful at doing this. Then once we're done with this step, Kelly is going to take care of the rest of these for us and make them a little bit more complete, move them over to the setup.

01:31 You can feel free to do that if you have a little bit more time too. So have a good time with that, and we'll see you when you're done.