Skip to content

Commit 180f89c

Browse files
test: update snaphots
1 parent 6c4dd60 commit 180f89c

File tree

5 files changed

+302
-11528
lines changed

5 files changed

+302
-11528
lines changed

test/api/__snapshots__/CLI.test.js.snap.webpack5

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ exports[`CLI API custom help output should display help for a command 1`] = `
3838
[
3939
" or markdown)",
4040
],
41-
[
42-
" -h, --help [verbose] Display help for commands and options.",
43-
],
4441
[
4542
"",
4643
],
@@ -71,9 +68,6 @@ exports[`CLI API custom help output should display help for a command 1`] = `
7168
[
7269
" ──────────────────────────────────────────────────────────────────────────",
7370
],
74-
[
75-
" ℹ Run 'webpack help version --verbose' to see all available options.",
76-
],
7771
[
7872
"",
7973
],

test/api/__snapshots__/ui-renderer.test.js.snap.webpack5

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ exports[`renderCommandHelp should match full output snapshot for build command 1
124124
" -h, --help [verbose] Display help for commands and options.",
125125
"",
126126
" ──────────────────────────────────────────────────────────────────────────",
127-
" ℹ Run 'webpack help build --verbose' to see all available options.",
128127
"",
129128
]
130129
`;
@@ -152,7 +151,6 @@ exports[`renderCommandHelp should match full output snapshot for info command 1`
152151
" -h, --help [verbose] Display help for commands and options.",
153152
"",
154153
" ──────────────────────────────────────────────────────────────────────────",
155-
" ℹ Run 'webpack help info --verbose' to see all available options.",
156154
"",
157155
]
158156
`;
@@ -231,25 +229,6 @@ exports[`renderOptionHelp should match snapshot with all fields 1`] = `
231229
]
232230
`;
233231

234-
exports[`renderStatsOutput should match snapshot for failed build 1`] = `
235-
[
236-
"
237-
ERROR in ./src/index.js
238-
Module not found: './missing'",
239-
"",
240-
" ✖ Compilation failed: 1 error",
241-
]
242-
`;
243-
244-
exports[`renderStatsOutput should match snapshot for successful build 1`] = `
245-
[
246-
"
247-
asset main.js 2 KiB [emitted]",
248-
"",
249-
" ✔ Compiled successfully in 120ms",
250-
]
251-
`;
252-
253232
exports[`renderSuccess should match snapshot 1`] = `
254233
[
255234
" ✔ all good",

test/api/ui-renderer.test.js

Lines changed: 15 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const {
1111
renderInfo,
1212
renderInfoOutput,
1313
renderOptionHelp,
14-
renderStatsOutput,
1514
renderSuccess,
1615
renderVersionOutput,
1716
renderWarning,
@@ -177,25 +176,25 @@ describe("renderVersionOutput", () => {
177176
describe("renderCommandHelp", () => {
178177
it("should render the command name in the header", async () => {
179178
const { captured, opts } = makeOpts();
180-
await renderCommandHelp(COMMAND_HELP_BUILD, opts, false);
179+
renderCommandHelp(COMMAND_HELP_BUILD, opts);
181180
expect(getOutput(captured)).toContain("webpack build");
182181
});
183182

184183
it("should render the command description", async () => {
185184
const { captured, opts } = makeOpts();
186-
await renderCommandHelp(COMMAND_HELP_BUILD, opts, false);
185+
renderCommandHelp(COMMAND_HELP_BUILD, opts);
187186
expect(getOutput(captured)).toContain("Run webpack");
188187
});
189188

190189
it("should render the Usage line with aliases", async () => {
191190
const { captured, opts } = makeOpts();
192-
await renderCommandHelp(COMMAND_HELP_BUILD, opts, false);
191+
renderCommandHelp(COMMAND_HELP_BUILD, opts);
193192
expect(getOutput(captured)).toContain("build|bundle|b");
194193
});
195194

196195
it("should render all option flags", async () => {
197196
const { captured, opts } = makeOpts();
198-
await renderCommandHelp(COMMAND_HELP_BUILD, opts, false);
197+
renderCommandHelp(COMMAND_HELP_BUILD, opts);
199198
const output = getOutput(captured);
200199
expect(output).toContain("--config");
201200
expect(output).toContain("--mode");
@@ -204,34 +203,34 @@ describe("renderCommandHelp", () => {
204203

205204
it("should render all option descriptions", async () => {
206205
const { captured, opts } = makeOpts();
207-
await renderCommandHelp(COMMAND_HELP_BUILD, opts, false);
206+
renderCommandHelp(COMMAND_HELP_BUILD, opts);
208207
const output = getOutput(captured);
209208
expect(output).toContain("Provide path");
210209
expect(output).toContain("watch mode");
211210
});
212211

213212
it("should render the Options section header", async () => {
214213
const { captured, opts } = makeOpts();
215-
await renderCommandHelp(COMMAND_HELP_BUILD, opts, false);
214+
renderCommandHelp(COMMAND_HELP_BUILD, opts);
216215
expect(getOutput(captured)).toContain("Options");
217216
});
218217

219218
it("should render the Global options section header", async () => {
220219
const { captured, opts } = makeOpts();
221-
await renderCommandHelp(COMMAND_HELP_BUILD, opts, false);
220+
renderCommandHelp(COMMAND_HELP_BUILD, opts);
222221
expect(getOutput(captured)).toContain("Global options");
223222
});
224223

225224
it("should render global option flags", async () => {
226225
const { captured, opts } = makeOpts();
227-
await renderCommandHelp(COMMAND_HELP_BUILD, opts, false);
226+
renderCommandHelp(COMMAND_HELP_BUILD, opts);
228227
expect(getOutput(captured)).toContain("--color");
229228
expect(getOutput(captured)).toContain("--no-color");
230229
});
231230

232231
it("should use the same column width for Options and Global options", async () => {
233232
const { captured, opts } = makeOpts();
234-
await renderCommandHelp(COMMAND_HELP_BUILD, opts, false);
233+
renderCommandHelp(COMMAND_HELP_BUILD, opts);
235234
const optionLines = captured.filter((l) => stripAnsi(l).startsWith(" -"));
236235
const descStarts = optionLines
237236
.map((l) => {
@@ -249,14 +248,14 @@ describe("renderCommandHelp", () => {
249248
options: [{ flags: "--very-long-option-name", description: "A ".repeat(80).trim() }],
250249
};
251250
const { captured, opts } = makeOpts(80);
252-
await renderCommandHelp(longDesc, opts, false);
251+
renderCommandHelp(longDesc, opts);
253252
const overflowing = captured.filter((l) => stripAnsi(l).length > 82);
254253
expect(overflowing).toHaveLength(0);
255254
});
256255

257256
it("should work for the info command", async () => {
258257
const { captured, opts } = makeOpts();
259-
await renderCommandHelp(COMMAND_HELP_INFO, opts, false);
258+
renderCommandHelp(COMMAND_HELP_INFO, opts);
260259
const output = getOutput(captured);
261260
expect(output).toContain("webpack info");
262261
expect(output).toContain("--output");
@@ -265,7 +264,7 @@ describe("renderCommandHelp", () => {
265264

266265
it("should not overflow terminal width", async () => {
267266
const { captured, opts } = makeOpts(80);
268-
await renderCommandHelp(COMMAND_HELP_BUILD, opts, false);
267+
renderCommandHelp(COMMAND_HELP_BUILD, opts);
269268
const overflowing = captured.filter((l) => stripAnsi(l).length > 82);
270269
expect(overflowing).toHaveLength(0);
271270
});
@@ -276,19 +275,19 @@ describe("renderCommandHelp", () => {
276275
description: `Description for option ${i}`,
277276
}));
278277
const { captured, opts } = makeOpts();
279-
await renderCommandHelp({ ...COMMAND_HELP_BUILD, options: manyOptions }, opts, false);
278+
renderCommandHelp({ ...COMMAND_HELP_BUILD, options: manyOptions }, opts);
280279
expect(captured.filter((l) => l.includes("--option-"))).toHaveLength(40);
281280
});
282281

283282
it("should match full output snapshot for build command", async () => {
284283
const { captured, opts } = makeOpts();
285-
await renderCommandHelp(COMMAND_HELP_BUILD, opts, false);
284+
renderCommandHelp(COMMAND_HELP_BUILD, opts);
286285
expect(captured).toMatchSnapshot();
287286
});
288287

289288
it("should match full output snapshot for info command", async () => {
290289
const { captured, opts } = makeOpts();
291-
await renderCommandHelp(COMMAND_HELP_INFO, opts, false);
290+
renderCommandHelp(COMMAND_HELP_INFO, opts);
292291
expect(captured).toMatchSnapshot();
293292
});
294293
});
@@ -371,63 +370,6 @@ describe("renderCommandFooter", () => {
371370
});
372371
});
373372

374-
describe("renderStatsOutput", () => {
375-
it("should indent each line of the stats string", () => {
376-
const { captured, opts } = makeOpts();
377-
renderStatsOutput("asset main.js 2 KiB [emitted]", { success: true, message: "OK" }, opts);
378-
const statsEntry = captured.find((line) => line.includes("asset main.js"));
379-
expect(statsEntry).toBeDefined();
380-
const firstContentLine = statsEntry.split("\n").find((line) => line.includes("asset main.js"));
381-
expect(firstContentLine.startsWith(" ".repeat(INDENT))).toBe(true);
382-
});
383-
384-
it("should render success summary with ✔", () => {
385-
const { captured, opts } = makeOpts();
386-
renderStatsOutput("", { success: true, message: "Compiled successfully" }, opts);
387-
expect(getOutput(captured)).toContain("✔");
388-
expect(getOutput(captured)).toContain("Compiled successfully");
389-
});
390-
391-
it("should render error summary with ✖", () => {
392-
const { captured, opts } = makeOpts();
393-
renderStatsOutput("", { success: false, message: "Build failed" }, opts);
394-
expect(getOutput(captured)).toContain("✖");
395-
expect(getOutput(captured)).toContain("Build failed");
396-
});
397-
398-
it("should handle empty stats string gracefully", () => {
399-
const { captured, opts } = makeOpts();
400-
expect(() => renderStatsOutput("", null, opts)).not.toThrow();
401-
expect(captured).toHaveLength(0);
402-
});
403-
404-
it("should handle whitespace-only stats string", () => {
405-
const { captured, opts } = makeOpts();
406-
renderStatsOutput(" \n ", null, opts);
407-
expect(captured).toHaveLength(0);
408-
});
409-
410-
it("should match snapshot for successful build", () => {
411-
const { captured, opts } = makeOpts();
412-
renderStatsOutput(
413-
"asset main.js 2 KiB [emitted]",
414-
{ success: true, message: "Compiled successfully in 120ms" },
415-
opts,
416-
);
417-
expect(captured).toMatchSnapshot();
418-
});
419-
420-
it("should match snapshot for failed build", () => {
421-
const { captured, opts } = makeOpts();
422-
renderStatsOutput(
423-
"ERROR in ./src/index.js\nModule not found: './missing'",
424-
{ success: false, message: "Compilation failed: 1 error" },
425-
opts,
426-
);
427-
expect(captured).toMatchSnapshot();
428-
});
429-
});
430-
431373
describe("renderOptionHelp", () => {
432374
it("should render option name in header", () => {
433375
const { captured, opts } = makeOpts();

0 commit comments

Comments
 (0)