So you'll save time and that one out of 10 times, well... Yeah, great sum up. Yeah, that's the sum up. Yeah.
Another question from our active questioner, anonymous, how do you change the mock response per test so that you can test different scenarios in a test specification? Yeah. So that's one of the parts I had to cut because usually at the end of this talk I have a small demo, but well, we have 20 minutes. Pretty much you can define the entire contract, it has answers, it's request response, resolvers, and response. I forgot how to speak, sorry. Like Sara was just saying a couple of minutes ago, native is not my English not my native English, sorry, my brain just went on to answer this thing. Basically you can define the entire contract, but then for each specific test, you can go ahead, you can get access to the server instance that you're using, or in this case to the, yeah, to the server instance and you can say, okay, for this specific test, I want you to use this response resolver. And you can say only for this specific test, you override it. And then everything after that, that's just reset to the default. So pretty much you can customize specific scenarios for specific tests, which makes it a bit more simple than, for instance, setting up stuff like a mock server, if you had experiences of setting up mock servers, that's a huge pain, especially when scenarios like this, because then you have to go ahead and say, oh, okay, for this specific scenario, when I received this parameter, I want you to throw an error. With mock service worker, you don't need to just import the server that you're using to listen to everything and say, okay, for this specific test, I'm doing this and it just works out of the box. That's not a lot of setup that you need to do that. Awesome. Thanks.
Next question from Anonymous, how do you maintain the contract? Does mock service worker import Swagger, for example? Oh, that's a great question. I've been trying to see if that exists for a bit. I think it doesn't exist yet. So there's an opportunity, if any of you wants to try it out. I've been wanting to, but I haven't had the time yet. So usually what I've been doing is, the contract that I had in my team, usually when you build APIs, you either add most of it, or you can remove. But it's easy to remove. It's just go there and delete. And when there are small changes, you can go there in a specific scenario and just tweak it by hand. Obviously it would be ideal if we had something that could improve import from Swagger, like this example here. It would be really good, but to my knowledge, it still doesn't exist. I can question Artem, and I'll try to get back to this on Twitter or on LinkedIn, but it would be really, really good. Nice.
Comments