Skip to content

Commit 2c28bcf

Browse files
committed
test: ✅ adjust tests
1 parent 62f7edc commit 2c28bcf

File tree

14 files changed

+27
-44
lines changed

14 files changed

+27
-44
lines changed

tests/e2e/cases/chunk/recover-error/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { test, expect } from "@/fixtures";
22
import path from "path";
33

44
test("should error with invalid syntax", async ({ page, fileAction, rspack }) => {
5-
const codePath = path.resolve(rspack.outDir, "AppIndex.js");
5+
const codePath = path.resolve(rspack.outDir, "src_AppIndex_jsx.js");
66
await expect(page.locator("button")).toHaveText("count is 0");
77
await page.click("button");
88
await expect(page.locator("button")).toHaveText("count is 1");

tests/e2e/cases/css/import-empty-css-file/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ import { test, expect } from "@/fixtures";
33
test("should not throw error for importing empty css files", async ({
44
page
55
}) => {
6-
expect(await page.textContent("#root")).toBe("ok");
6+
await expect(page.locator("#root")).toHaveText("ok");
77
});

tests/e2e/cases/file/context-delete-file/index.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ test("delete file should work", async ({
77
rspack
88
}) => {
99
// asset page status
10-
const statusText = await page.textContent("#root");
11-
expect(statusText).toBe("__PAGE_RENDER__");
10+
await expect(page.locator("#root")).toHaveText("__PAGE_RENDER__");
1211
// asset script content
1312
const response = await request.get(
14-
`http://localhost:${rspack.devServer.options.port}/main.js`
13+
`http://localhost:${rspack.devServer.options.port}/src_index_js.js`
1514
);
1615
const bodyResponse = (await response.body()).toString();
1716
expect(bodyResponse).toContain("this is mod1");
@@ -21,7 +20,7 @@ test("delete file should work", async ({
2120
await expect(page.locator("#root")).toHaveText("__HMR_UPDATED__");
2221
// asset new script content
2322
const responseAfterDelete = await request.get(
24-
`http://localhost:${rspack.devServer.options.port}/main.js`
23+
`http://localhost:${rspack.devServer.options.port}/src_index_js.js`
2524
);
2625
const bodyResponseAfterDelete = (await responseAfterDelete.body()).toString();
2726
expect(bodyResponseAfterDelete).not.toContain("this is mod1");

tests/e2e/cases/hooks/asset-emitted/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ test("asset emitted hook should only emit modified assets", async ({
88
const assets = (rspack.compiler as any).assets;
99
// reset assets
1010
assets.length = 0;
11-
expect(await page.textContent("#root")).toBe("__ROOT_TEXT____FOO_VALUE__");
11+
await expect(page.locator("#root")).toHaveText("__ROOT_TEXT____FOO_VALUE__");
1212

1313
// update js file
1414
fileAction.updateFile("src/index.js", content => {

tests/e2e/cases/hooks/asset-emitted/rspack.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ module.exports = {
2222
optimization: {
2323
chunkIds: "named"
2424
},
25-
output: { clean: true }
25+
output: { clean: true },
26+
lazyCompilation: false,
2627
};

tests/e2e/cases/html/cross-origin-loading/rspack.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@ module.exports = {
1616
},
1717
devServer: {
1818
port: 3000
19-
}
19+
},
20+
// for concise assert for assets
21+
lazyCompilation: false
2022
};

tests/e2e/cases/make/remove-dynamic-entry-with-loader/index.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { expect, test } from "@/fixtures";
22

33
test("should compile", async ({ page, fileAction, rspack }) => {
44
// rspack.compiler.__sharedObj is injected by plugin in rspack.config.js
5-
await expect(page.getByText("index1")).toBeVisible();
6-
await expect(page.getByText("index2")).toBeVisible();
5+
await expect(page.locator("#index1")).toHaveText("index1");
6+
await expect(page.locator("#index2")).toHaveText("index2");
77

88
rspack.compiler.__sharedObj.useFullEntry = false;
99
fileAction.updateFile("src/index2.js", content =>
@@ -23,6 +23,7 @@ test("should compile", async ({ page, fileAction, rspack }) => {
2323
await page.reload();
2424
expect(await page.locator("#index1").innerText()).toBe("index1 updated");
2525
}).toPass();
26+
2627
await expect(page.locator("#index2")).toHaveCount(0);
2728
await expect(page.locator("#webpack-dev-server-client-overlay")).toHaveCount(
2829
0

tests/e2e/cases/make/remove-dynamic-entry-with-loader/rspack.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@ module.exports = {
3434
],
3535
devServer: {
3636
hot: true
37-
}
37+
},
38+
lazyCompilation: false,
3839
};

tests/e2e/cases/make/remove-dynamic-entry/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { expect, test } from "@/fixtures";
22

33
test("should compile", async ({ page, fileAction, rspack }) => {
4-
await expect(page.getByText("index1")).toBeVisible();
5-
await expect(page.getByText("index2")).toBeVisible();
4+
await expect(page.locator("#index1")).toBeVisible();
5+
await expect(page.locator("#index2")).toBeVisible();
66

77
fileAction.deleteFile("src/index2.js");
88
fileAction.updateFile("src/index1.js", content => content.replace("div.innerText = \"index1\";", "div.innerText = \"index1 updated\";"));

tests/e2e/cases/make/remove-dynamic-entry/rspack.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,7 @@ module.exports = {
2222
devServer: {
2323
hot: true
2424
},
25+
lazyCompilation: {
26+
entries: false
27+
}
2528
};

0 commit comments

Comments
 (0)