Rayrun
← Back to Discord Forum

Mocking API multiple responses

I have a polling API where after a certain amount of time the response may change. I would like to be able to return a different response after a certain number of calls. Is there a mechanism to do this?

Thank you!

This thread is trying to answer question "Is there a mechanism to return a different response after a certain number of calls in a polling API?"

1 reply

You can do whatever inside your route handler https://playwright.dev/docs/api/class-page#page-route-option-handler like store the time when creating the handler and inside compare the current time. Or use the 'times' option and a second handler that will take over handling the route as soon as the first handler reaches its usage limit.

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].