Rayrun
← Back to Discord Forum

Intercepting API to avoid rate limit

caesarsaladposted in #help-playwright
Open in Discord

hi all, when i started my project and wants to make use of parallelism in playwright, i encountered an issue where i got rate-limited. imagine i am running 3 tests in parallel, each of which will call this endpoint /createProject. so i mock the API using page.route. however this does not solve my problem, it seems like the actual API endpoint is still being hit. may i know if there's a way to intercept the API properly? thanks!

This thread is trying to answer question "Is there a way to properly intercept an API to avoid rate limits while running parallel tests in Playwright?"

3 replies

Mocking the api usually works. https://playwright.dev/docs/mock "Devil lies in the details" so share some code (maybe) to see why the endpoint is being hit.

refactoreric

Hi, maybe the third party API is being called by your backend service, and not by the frontend?

For mocking dependencies of your backend, you will need to use other solutions, like Wiremock, and configure the test environment to connect to that mock service instead of the real thing.

the APIs are actually being intercepted, i got the endpoints mixed up 🫣 my bad

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 luc@ray.run.