Created
July 31, 2024 16:13
-
-
Save joekrump/604302dda5f382e82ca11dc2146ee723 to your computer and use it in GitHub Desktop.
Playwright mock slow network request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const urlPattern = "**/some_endpoint"; | |
const delayMS = 1000 | |
await page.route(urlPattern, async (route) => { | |
const resolve = (route: Route) => route.continue(); | |
const res = new Promise(() => resolve); | |
setTimeout(async () => { | |
await resolve(route); | |
}, delayMS); | |
return await res; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment