Skip to content

Commit efd91ca

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 efd91ca

2 files changed

Lines changed: 20 additions & 4 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: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,14 @@ describe("multi-compiler (browser)", () => {
121121
}
122122
`;
123123

124+
// The widget starts clean so the connect-time catch-up sync carries no
125+
// problems — whether a still-evaluating bundle misses it (the shared
126+
// connection writes it once) then cannot change the sequence. The
127+
// warning enters through a build the page observes.
124128
app = await createHotApp({
125129
apps: [
126130
{ name: "app", code: bundleApp("app", "app-v1") },
127-
{ name: "widget", code: widgetWithWarning("widget-v1") },
131+
{ name: "widget", code: bundleApp("widget", "widget-v1") },
128132
],
129133
});
130134
({ page, browser } = await runBrowser());
@@ -133,20 +137,25 @@ describe("multi-compiler (browser)", () => {
133137
await page.goto(app.url);
134138
await waitForText(page, "out-app", "app-v1");
135139
await waitForText(page, "out-widget", "widget-v1");
136-
// The widget's warning arrives with the connect-time sync, logged once.
140+
await console_.waitFor("connected");
141+
142+
// The widget picks up the warning: logged once with its build.
143+
app.edit("widget", widgetWithWarning("widget-v1b"));
144+
await waitForText(page, "out-widget", "widget-v1b");
137145
await console_.waitFor("Critical dependency");
146+
await console_.waitFor("App is up to date");
138147

139148
// A sibling's clean rebuild must NOT re-log the widget's unchanged
140149
// warning (the console cache is per bundle).
141150
app.edit("app", bundleApp("app", "app-v2"));
142151
await waitForText(page, "out-app", "app-v2");
143-
await console_.waitFor("App is up to date");
152+
await console_.waitForCount("App is up to date", 2);
144153

145154
// The widget's own rebuild drops its cache, so the identical warning
146155
// text is logged again.
147156
app.edit("widget", widgetWithWarning("widget-v2"));
148157
await waitForText(page, "out-widget", "widget-v2");
149-
await console_.waitForCount("App is up to date", 2);
158+
await console_.waitForCount("App is up to date", 3);
150159

151160
expect(normalizeConsole(console_.messages)).toMatchSnapshot();
152161
});

0 commit comments

Comments
 (0)