Browse Source

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

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

33
tests/playwright/pages/Base.ts

@ -28,22 +28,27 @@ 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(
let isResJsonMatched = true; res => {
if (responseJsonMatcher) { let isResJsonMatched = true;
try { if (responseJsonMatcher) {
isResJsonMatched = responseJsonMatcher(await res.json()); try {
} catch (e) { isResJsonMatched = responseJsonMatcher(res.json());
return false; } catch (e) {
return false;
}
} }
}
return ( return (
res.request().url().includes(requestUrlPathToMatch) && res.request().url().includes(requestUrlPathToMatch) &&
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