Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Mocking the same endpoint multiple times in one test #5747

Closed
nirbenya opened this issue Mar 6, 2021 · 2 comments
Closed

[Question] Mocking the same endpoint multiple times in one test #5747

nirbenya opened this issue Mar 6, 2021 · 2 comments

Comments

@nirbenya
Copy link

nirbenya commented Mar 6, 2021

So my scenario is this:
I wanna mock an endpoint multiple times.
for example: '/api/v1/auth/user' will return with status 401 on the first time it's get called, but on the second time it's get called I wanna get a a different response (let's say with status 200).
While I'm able to mock the first call successfully using route.fulfill, I didn't find a way to override it on the second call.
Didn't find any documentation on the docs or on the web about it.

Is it even possible?

Thanks

@pavelfeldman
Copy link
Member

route will handle all the requests, not just the first one. You can put code that handles request differently every time, or you can unroute and route with the new handler.

@yury-s
Copy link
Member

yury-s commented Mar 10, 2021

Closing per response above, please reopen if you need further help.

@yury-s yury-s closed this as completed Mar 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants