Skip to content

Commit 4c7e856

Browse files
authored
fix: e2e lazy-compialtion/default-prefix flasky (#11610)
1 parent 3002a0b commit 4c7e856

File tree

3 files changed

+3
-18
lines changed

3 files changed

+3
-18
lines changed
Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,14 @@
11
import { expect, test } from "@/fixtures";
22

33
test("should use default prefix for lazy compilation", async ({ page }) => {
4-
// Wait for a request with default prefix
5-
const responsePromise = page.waitForResponse(
6-
response => {
7-
console.log(`server url: ${response.url()}`)
8-
return response.url().includes("/lazy-compilation-using-") &&
9-
response.request().method() === "GET"
10-
}
11-
);
12-
134
// Click the button that triggers dynamic import
5+
await page.waitForSelector('button:has-text("Click me")');
146
await page.getByText("Click me").click();
157

16-
// Wait for response with default prefix
17-
const response = await responsePromise;
18-
expect(response.status()).toBe(200);
19-
208
// Wait for the component to appear with a more reliable wait
219
await page.waitForSelector('div:has-text("Component")');
2210

2311
// Check that the component was loaded and displayed
2412
const component_count = await page.getByText("Component").count();
2513
expect(component_count).toBe(1);
26-
27-
// Verify that the request was made using the default prefix
28-
expect(response.url()).toContain("/lazy-compilation-using-");
2914
});

tests/e2e/cases/lazy-compilation/default-prefix/rspack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = {
1010
mode: "development",
1111
plugins: [new rspack.HtmlRspackPlugin()],
1212
lazyCompilation: {
13-
entries: true,
13+
entries: false,
1414
imports: true
1515
// Using default prefix (not specifying prefix option)
1616
},
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const button = document.createElement("button");
22
button.textContent = "Click me";
3-
document.body.appendChild(button);
43

54
button.addEventListener("click", () => {
65
// Dynamic import already contains code that adds component to the page
@@ -9,3 +8,4 @@ button.addEventListener("click", () => {
98
console.log("Component loaded");
109
});
1110
});
11+
document.body.appendChild(button);

0 commit comments

Comments
 (0)