Browse Source

fix(playwright): waitForResponse

pull/5903/head
Wing-Kam Wong 1 year ago
parent
commit
476600ddd5
  1. 7
      tests/playwright/pages/Base.ts

7
tests/playwright/pages/Base.ts

@ -29,11 +29,11 @@ export default abstract class BasePage {
responseJsonMatcher?: ResponseSelector; responseJsonMatcher?: ResponseSelector;
}) { }) {
const waitForResponsePromise = this.rootPage.waitForResponse( const waitForResponsePromise = this.rootPage.waitForResponse(
res => { async res => {
let isResJsonMatched = true; let isResJsonMatched = true;
if (responseJsonMatcher) { if (responseJsonMatcher) {
try { try {
isResJsonMatched = responseJsonMatcher(res.json()); isResJsonMatched = responseJsonMatcher(await res.json());
} catch (e) { } catch (e) {
return false; return false;
} }
@ -50,8 +50,7 @@ export default abstract class BasePage {
} }
); );
await uiAction(); await Promise.all([uiAction(), waitForResponsePromise]);
await waitForResponsePromise;
} }
async attachFile({ filePickUIAction, filePath }: { filePickUIAction: Promise<any>; filePath: string[] }) { async attachFile({ filePickUIAction, filePath }: { filePickUIAction: Promise<any>; filePath: string[] }) {

Loading…
Cancel
Save