Browse Source

fix(playwright): add timeout and remove async inside waitForResponse

pull/5903/head
Wing-Kam Wong 1 year ago
parent
commit
e0d820f45d
  1. 11
      tests/playwright/pages/Base.ts

11
tests/playwright/pages/Base.ts

@ -28,11 +28,12 @@ export default abstract class BasePage {
httpMethodsToMatch?: string[]; httpMethodsToMatch?: string[];
responseJsonMatcher?: ResponseSelector; responseJsonMatcher?: ResponseSelector;
}) { }) {
const waitForResponsePromise = this.rootPage.waitForResponse(async res => { const waitForResponsePromise = this.rootPage.waitForResponse(
res => {
let isResJsonMatched = true; let isResJsonMatched = true;
if (responseJsonMatcher) { if (responseJsonMatcher) {
try { try {
isResJsonMatched = responseJsonMatcher(await res.json()); isResJsonMatched = responseJsonMatcher(res.json());
} catch (e) { } catch (e) {
return false; return false;
} }
@ -43,7 +44,11 @@ export default abstract class BasePage {
httpMethodsToMatch.includes(res.request().method()) && httpMethodsToMatch.includes(res.request().method()) &&
isResJsonMatched isResJsonMatched
); );
}); },
{
timeout: 100000,
}
);
await uiAction(); await uiAction();
await waitForResponsePromise; await waitForResponsePromise;

Loading…
Cancel
Save