Skip to content

Commit d724027

Browse files
committed
test: add test case for remove-optimized-module
1 parent e0e2e12 commit d724027

File tree

6 files changed

+47
-0
lines changed

6 files changed

+47
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const Button = "Button";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { Button } from "./Button";
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { Button } from "./comp";
2+
3+
const div = document.createElement("div");
4+
div.id = "main";
5+
div.innerText = Button;
6+
document.body.appendChild(div);
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { test, expect } from "@/fixtures";
2+
3+
test("remove optimized module should not panic", async ({
4+
page,
5+
fileAction
6+
}) => {
7+
await expect(page.locator("#main")).toHaveText("Button");
8+
9+
fileAction.deleteFile("comp/Button.js");
10+
11+
const overlay = page.frameLocator("#webpack-dev-server-client-overlay");
12+
await expect(
13+
overlay.getByText("ESModulesLinkingWarning: export 'Button'")
14+
).toBeVisible();
15+
await expect(
16+
overlay.getByText("Module not found: Can't resolve './Button'")
17+
).toBeVisible();
18+
19+
fileAction.updateFile(
20+
"comp/Button.js",
21+
() => "export const Button = 'NewButton';"
22+
);
23+
await expect(page.locator("#main")).toHaveText("NewButton");
24+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "test",
3+
"sideEffects": false
4+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const { rspack } = require("@rspack/core");
2+
3+
/** @type {import("@rspack/core").Configuration} */
4+
module.exports = {
5+
entry: "./index.js",
6+
cache: true,
7+
experiments: {
8+
cache: true
9+
},
10+
plugins: [new rspack.HtmlRspackPlugin()]
11+
};

0 commit comments

Comments
 (0)