From afccf3d8c9050b222368ab8953f558da91e2d36d Mon Sep 17 00:00:00 2001 From: Peng Xiao Date: Tue, 6 Feb 2024 03:20:48 +0000 Subject: [PATCH] feat(core): add an option to throttle cpu in e2e (#5803) To debug e2e flakyness locally --- tests/kit/playwright.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/kit/playwright.ts b/tests/kit/playwright.ts index 0a0b42398..6279afbff 100644 --- a/tests/kit/playwright.ts +++ b/tests/kit/playwright.ts @@ -67,6 +67,15 @@ export const test = baseTest.extend<{ }, }); }, + page: async ({ page, context }, use) => { + if (process.env.CPU_THROTTLE) { + const cdpSession = await context.newCDPSession(page); + await cdpSession.send('Emulation.setCPUThrottlingRate', { + rate: parseInt(process.env.CPU_THROTTLE), + }); + } + await use(page); + }, context: async ({ context }, use) => { // workaround for skipping onboarding redirect on the web await skipOnboarding(context);