From 476600ddd57a9a0c58b8bb21341f55c4025e5e2e Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sun, 18 Jun 2023 00:37:24 +0800 Subject: [PATCH] fix(playwright): waitForResponse --- tests/playwright/pages/Base.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/playwright/pages/Base.ts b/tests/playwright/pages/Base.ts index dddc99f238..6dca0b1246 100644 --- a/tests/playwright/pages/Base.ts +++ b/tests/playwright/pages/Base.ts @@ -29,11 +29,11 @@ export default abstract class BasePage { responseJsonMatcher?: ResponseSelector; }) { const waitForResponsePromise = this.rootPage.waitForResponse( - res => { + async res => { let isResJsonMatched = true; if (responseJsonMatcher) { try { - isResJsonMatched = responseJsonMatcher(res.json()); + isResJsonMatched = responseJsonMatcher(await res.json()); } catch (e) { return false; } @@ -50,8 +50,7 @@ export default abstract class BasePage { } ); - await uiAction(); - await waitForResponsePromise; + await Promise.all([uiAction(), waitForResponsePromise]); } async attachFile({ filePickUIAction, filePath }: { filePickUIAction: Promise; filePath: string[] }) {