Skip to content

Commit

Permalink
test: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Jan 23, 2024
1 parent ba0a2fc commit 555bddd
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 22 deletions.
3 changes: 1 addition & 2 deletions test/e2e/__snapshots__/overlay.test.js.snap.webpack5
Original file line number Diff line number Diff line change
Expand Up @@ -2312,8 +2312,7 @@ exports[`overlay should show error for uncaught runtime error: overlay html 1`]
"
>
Injected error at throwError (<anonymous>:2:15) at
<anonymous>:3:9 at addScriptContent
(__puppeteer_evaluation_script__:9:27)
<anonymous>:3:9
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ exports[`web socket server URL should work and throw an error on invalid web soc

exports[`web socket server URL should work and throw an error on invalid web socket URL ("sockjs"): page errors 1`] = `
[
"SyntaxError: The URL's scheme must be either 'http:' or 'https:'. 'unknown:' is not allowed.",
"The URL's scheme must be either 'http:' or 'https:'. 'unknown:' is not allowed.",
]
`;

Expand All @@ -45,7 +45,7 @@ exports[`web socket server URL should work and throw an error on invalid web soc

exports[`web socket server URL should work and throw an error on invalid web socket URL ("ws"): page errors 1`] = `
[
"DOMException: Failed to construct 'WebSocket': The URL's scheme must be either 'ws' or 'wss'. 'unknown' is not allowed.",
"Failed to construct 'WebSocket': The URL's scheme must be either 'ws' or 'wss'. 'unknown' is not allowed.",
]
`;

Expand Down
2 changes: 2 additions & 0 deletions test/e2e/on-listening.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ describe("onListening option", () => {
pageErrors.push(error);
})
.on("request", (interceptedRequest) => {
if (interceptedRequest.isInterceptResolutionHandled()) return;

interceptedRequest.continue({ method: "POST" });
});

Expand Down
46 changes: 28 additions & 18 deletions test/e2e/options-middleware.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,33 @@ describe("handle options-request correctly", () => {
const prefixUrl = "http://127.0.0.1";
const htmlUrl = `${prefixUrl}:${portForServer}/test.html`;
const appUrl = `${prefixUrl}:${portForApp}`;
await page.goto(appUrl);
const responseStatus = [];
page.on("response", (res) => {
responseStatus.push(res.status());
});
await page.evaluate(
(url) =>
window.fetch(url, {
headers: {
"another-header": "1",
},
}),
htmlUrl,
);
await browser.close();
await server.stop();
await closeApp();
expect(responseStatus).toEqual([204, 200]);

try {
await page.goto(appUrl);

const responseStatus = [];

page.on("response", (res) => {
responseStatus.push(res.status());
});

await page.evaluate(
(url) =>
window.fetch(url, {
headers: {
"another-header": "1",
},
}),
htmlUrl,
);

expect(responseStatus).toEqual([200, 204, 200]);
} catch (error) {
throw error;
} finally {
await browser.close();
await server.stop();
await closeApp();
}
});
});

0 comments on commit 555bddd

Please sign in to comment.