Current section: HTTP Mocking 5 exercises

Streamlining Repetitive Test Setup for Optimal Efficiency

Loading exercise


00:00 Another important testing principle is avoiding repeating yourself but not going so far into dry, don't repeat yourself. You want to avoid hasty abstractions. But that said, there are definitely some abstractions that we can very clearly see in here. There's some setup for

00:17 having an authenticated request, like a request that's all set up with the GitHub Auth flow being ready. And so that would be really nice to have as a separate function. And the reason like this is all just like JavaScript stuff, right? You just make a function out of the thing that you do a lot. But I just see this a lot where people will copy a test and paste it and keep

00:38 on pasting it. Or they'll do like really nested described blocks with before each is and shared variables. And it's, it's a nightmare. So I want to show you the proper way to do this so that you can be as successful as possible as you're making these types of kind of, in some ways, repetitive tests, especially when there's a lot of repeat setup.

00:58 So give that a whirl, and we'll see you when you're done.