Skip to content

Commit 2347b6d

Browse files
committed
refactor(tests): tighten assertions and remove unused console.log
1 parent 647fae9 commit 2347b6d

1 file changed

Lines changed: 22 additions & 44 deletions

File tree

packages/integration-tests/fixtures/vite-mpa-extra-modules/vite-mpa-extra-modules.test.ts

Lines changed: 22 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -48,78 +48,56 @@ describe("Vite MPA Extra Modules Issue (#829)", () => {
4848
}
4949

5050
// Build without plugin
51-
childProcess.execSync(
52-
`yarn ts-node ${path.join(__dirname, "build-vite-without-plugin.ts")}`,
53-
{ encoding: "utf-8", stdio: "inherit" }
54-
);
51+
childProcess.execSync(`yarn ts-node ${path.join(__dirname, "build-vite-without-plugin.ts")}`, {
52+
encoding: "utf-8",
53+
stdio: "inherit",
54+
});
5555

5656
// Build with plugin
57-
childProcess.execSync(
58-
`yarn ts-node ${path.join(__dirname, "build-vite-with-plugin.ts")}`,
59-
{ encoding: "utf-8", stdio: "inherit" }
60-
);
57+
childProcess.execSync(`yarn ts-node ${path.join(__dirname, "build-vite-with-plugin.ts")}`, {
58+
encoding: "utf-8",
59+
stdio: "inherit",
60+
});
6161
}, 60_000);
6262

6363
it("should not create extra JS modules when sentry plugin is enabled", () => {
6464
const assetsWithoutPlugin = getAssetFiles(outWithoutPlugin);
6565
const assetsWithPlugin = getAssetFiles(outWithPlugin);
6666

67-
console.log("Assets without plugin:", assetsWithoutPlugin);
68-
console.log("Assets with plugin:", assetsWithPlugin);
69-
7067
// The number of JS files should be the same (or very close)
7168
// With the bug, the plugin creates extra modules like index.js, page1.js, page2.js
7269
// for each HTML entry point
73-
expect(assetsWithPlugin.length).toBeLessThanOrEqual(assetsWithoutPlugin.length + 1);
70+
expect(assetsWithPlugin).toHaveLength(assetsWithoutPlugin.length);
7471
});
7572

7673
it("should not add script tags to HTML pages that had none", () => {
7774
// index.html originally has no scripts
78-
const indexWithoutPlugin = getScriptTagsFromHtml(
79-
path.join(outWithoutPlugin, "index.html")
80-
);
81-
const indexWithPlugin = getScriptTagsFromHtml(
82-
path.join(outWithPlugin, "index.html")
83-
);
84-
85-
console.log("index.html scripts without plugin:", indexWithoutPlugin);
86-
console.log("index.html scripts with plugin:", indexWithPlugin);
75+
const indexWithoutPlugin = getScriptTagsFromHtml(path.join(outWithoutPlugin, "index.html"));
76+
const indexWithPlugin = getScriptTagsFromHtml(path.join(outWithPlugin, "index.html"));
8777

8878
// The number of script tags should be the same
8979
// With the bug, index.html gets a script tag added even though it had none
90-
expect(indexWithPlugin.length).toBe(indexWithoutPlugin.length);
80+
expect(indexWithPlugin).toHaveLength(indexWithoutPlugin.length);
9181
});
9282

9383
it("should preserve shared module imports without creating page-specific wrappers", () => {
9484
// page1.html and page2.html should both reference the same shared module
9585
// not page-specific modules
96-
const page1WithPlugin = fs.readFileSync(
97-
path.join(outWithPlugin, "page1.html"),
98-
"utf-8"
99-
);
100-
const page2WithPlugin = fs.readFileSync(
101-
path.join(outWithPlugin, "page2.html"),
102-
"utf-8"
103-
);
86+
const page1WithPlugin = fs.readFileSync(path.join(outWithPlugin, "page1.html"), "utf-8");
87+
const page2WithPlugin = fs.readFileSync(path.join(outWithPlugin, "page2.html"), "utf-8");
10488

10589
// Extract the JS file references
10690
const page1ScriptMatch = page1WithPlugin.match(/src="([^"]+\.js)"/);
10791
const page2ScriptMatch = page2WithPlugin.match(/src="([^"]+\.js)"/);
10892

109-
console.log("page1 script src:", page1ScriptMatch?.[1]);
110-
console.log("page2 script src:", page2ScriptMatch?.[1]);
111-
112-
if (page1ScriptMatch && page2ScriptMatch) {
113-
// Both pages should reference the same shared module, not page-specific ones
114-
// With the bug, page1.html references page1-xxx.js and page2.html references page2-xxx.js
115-
// instead of both referencing shared-module-xxx.js
116-
const page1Script = page1ScriptMatch[1];
117-
const page2Script = page2ScriptMatch[1];
93+
// Both pages should reference the same shared module, not page-specific ones
94+
// With the bug, page1.html references page1-xxx.js and page2.html references page2-xxx.js
95+
// instead of both referencing shared-module-xxx.js
96+
const page1Script = page1ScriptMatch?.[1];
97+
const page2Script = page2ScriptMatch?.[1];
11898

119-
// They should NOT be page-specific (named after the page)
120-
expect(page1Script).not.toMatch(/page1/i);
121-
expect(page2Script).not.toMatch(/page2/i);
122-
}
99+
// They should NOT be page-specific (named after the page)
100+
expect(page1Script).not.toMatch(/page1/i);
101+
expect(page2Script).not.toMatch(/page2/i);
123102
});
124103
});
125-

0 commit comments

Comments
 (0)