Skip to content

Commit 3de3b98

Browse files
committed
Mock redirects only when testing redirects
1 parent e737f87 commit 3de3b98

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

packages/npm-packages/ruby-wasm-wasi/test-e2e/integrations/js-require-remote.spec.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@ if (!process.env.RUBY_NPM_PACKAGE_ROOT) {
1313
route.fulfill({
1414
path: path.join("./test-e2e/integrations", relativePath),
1515
});
16-
} else if (relativePath.match("redirect_to_error_on_load_twice.rb")) {
17-
route.fulfill({
18-
status: 302,
19-
headers: {
20-
location: "error_on_load_twice.rb",
21-
},
22-
});
2316
} else if (fs.existsSync(mockedPath)) {
2417
route.fulfill({
2518
path: mockedPath,
@@ -92,13 +85,23 @@ if (!process.env.RUBY_NPM_PACKAGE_ROOT) {
9285
// In the integration test, response#url returns the URL before the redirect.
9386
// I do not know the cause. Under investigation.
9487
test.skip("JS::RequireRemote#load identifies by URL after redirect", async ({
95-
page,
88+
page, context
9689
}) => {
9790
// Stop tests immediately when an error occurs in the page.
9891
page.on("pageerror", (error) => {
9992
throw error;
10093
});
10194

95+
// Use the proxy to redirect the request.
96+
context.route(/redirect/, (route) => {
97+
route.fulfill({
98+
status: 302,
99+
headers: {
100+
location: "error_on_load_twice.rb",
101+
},
102+
});
103+
});
104+
102105
const resolve = await resolveBinding(page, "checkResolved");
103106
await page.goto(
104107
"https://cdn.jsdelivr.net/npm/ruby-head-wasm-wasi@latest/dist/",

0 commit comments

Comments
 (0)