Browse Source

test(playwright): try 30s timeout in waitForResponse

pull/5903/head
Wing-Kam Wong 1 year ago
parent
commit
08dc9c5e3f
  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(res => { const waitForResponsePromise = this.rootPage.waitForResponse(
let isResJsonMatched = true; res => {
if (responseJsonMatcher) { let isResJsonMatched = true;
try { if (responseJsonMatcher) {
isResJsonMatched = responseJsonMatcher(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: 30000,
}
);
await uiAction(); await uiAction();
await waitForResponsePromise; await waitForResponsePromise;

Loading…
Cancel
Save