Skip to content

Commit 60432e2

Browse files
bjohansebasclaude
andcommitted
test(e2e): make the warning-dedup sequence independent of the catch-up race
The shared SSE connection writes its catch-up sync once — a sibling bundle still evaluating when it arrives misses it, so a warning carried by that sync reached the console on some runs and not others. The widget now starts clean (an empty catch-up cannot vary the sequence) and picks its warning up through a build the page observes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 25d5dc5 commit 60432e2

2 files changed

Lines changed: 21 additions & 13 deletions

File tree

test/e2e/__snapshots__/multi-compiler.test.js.snap.webpack5

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,16 @@
33
exports[`multi-compiler (browser) logs per-bundle lifecycles and deduplicates warning re-logs on sibling builds 1`] = `
44
[
55
"[webpack-dev-middleware] connected",
6+
"[webpack-dev-middleware] bundle 'widget' rebuilding (<fixture> changed)",
7+
"[webpack-dev-middleware] bundle 'widget' rebuilding (<fixture> changed)",
8+
"[webpack-dev-middleware] bundle 'widget' rebuilt in Xms",
9+
"[webpack-dev-middleware] bundle 'widget' rebuilt in Xms",
610
"[webpack-dev-middleware] bundle 'widget' has 1 warnings",
711
"[webpack-dev-middleware] ./entry.js 11:8-20
812
Critical dependency: the request of a dependency is an expression",
13+
"[webpack-dev-middleware] Checking for updates on the server...",
14+
"[webpack-dev-middleware] Hot updated 2 modules.",
15+
"[webpack-dev-middleware] App is up to date.",
916
"[webpack-dev-middleware] bundle 'app' rebuilding (<fixture> changed)",
1017
"[webpack-dev-middleware] bundle 'app' rebuilding (<fixture> changed)",
1118
"[webpack-dev-middleware] bundle 'app' rebuilt in Xms",

test/e2e/multi-compiler.test.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,8 @@ describe("multi-compiler (browser)", () => {
9797
});
9898

9999
it("logs per-bundle lifecycles and deduplicates warning re-logs on sibling builds", async () => {
100-
// Warnings (unlike build errors) do not block applying updates or force
101-
// reloads, which keeps the console sequence deterministic enough to
102-
// snapshot. The `require(<expression>)` produces webpack's "Critical
103-
// dependency" warning; the template keeps it on a fixed line so the
104-
// warning text is identical across edits.
100+
// Warnings do not block applies or force reloads; the fixed-position
101+
// `require(<expression>)` keeps the warning text identical across edits.
105102
const widgetWithWarning = (text) => `
106103
let el = document.getElementById("out-widget");
107104
if (!el) {
@@ -121,10 +118,12 @@ describe("multi-compiler (browser)", () => {
121118
}
122119
`;
123120

121+
// The widget starts clean: an empty catch-up sync cannot vary the
122+
// sequence (a still-evaluating bundle may miss it entirely).
124123
app = await createHotApp({
125124
apps: [
126125
{ name: "app", code: bundleApp("app", "app-v1") },
127-
{ name: "widget", code: widgetWithWarning("widget-v1") },
126+
{ name: "widget", code: bundleApp("widget", "widget-v1") },
128127
],
129128
});
130129
({ page, browser } = await runBrowser());
@@ -133,20 +132,22 @@ describe("multi-compiler (browser)", () => {
133132
await page.goto(app.url);
134133
await waitForText(page, "out-app", "app-v1");
135134
await waitForText(page, "out-widget", "widget-v1");
136-
// The widget's warning arrives with the connect-time sync, logged once.
135+
await console_.waitFor("connected");
136+
137+
app.edit("widget", widgetWithWarning("widget-v1b"));
138+
await waitForText(page, "out-widget", "widget-v1b");
137139
await console_.waitFor("Critical dependency");
140+
await console_.waitFor("App is up to date");
138141

139-
// A sibling's clean rebuild must NOT re-log the widget's unchanged
140-
// warning (the console cache is per bundle).
142+
// A sibling's clean rebuild must not re-log the widget's warning.
141143
app.edit("app", bundleApp("app", "app-v2"));
142144
await waitForText(page, "out-app", "app-v2");
143-
await console_.waitFor("App is up to date");
145+
await console_.waitForCount("App is up to date", 2);
144146

145-
// The widget's own rebuild drops its cache, so the identical warning
146-
// text is logged again.
147+
// The widget's own rebuild drops its cache: same text logs again.
147148
app.edit("widget", widgetWithWarning("widget-v2"));
148149
await waitForText(page, "out-widget", "widget-v2");
149-
await console_.waitForCount("App is up to date", 2);
150+
await console_.waitForCount("App is up to date", 3);
150151

151152
expect(normalizeConsole(console_.messages)).toMatchSnapshot();
152153
});

0 commit comments

Comments
 (0)