vitest-auto-spy 5.12.0 → 5.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.js +42 -20
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -19,6 +19,7 @@ var VALUE_FLAGS = /* @__PURE__ */ new Set([
19
19
  "max-file-ms",
20
20
  "max-test-ms",
21
21
  "max-wall-ms",
22
+ "min-severity",
22
23
  "only",
23
24
  "out",
24
25
  "skip",
@@ -416,11 +417,12 @@ function formatOne(finding2) {
416
417
  "\n"
417
418
  );
418
419
  }
419
- function formatFindings(findings) {
420
- if (findings.length === 0) {
420
+ function formatFindings(findings, minSeverity = "info") {
421
+ const reported = findings.filter((finding2) => SEVERITY_ORDER[finding2.severity] <= SEVERITY_ORDER[minSeverity]);
422
+ if (reported.length === 0) {
421
423
  return "";
422
424
  }
423
- return sortFindings(findings).map(formatOne).join("\n\n");
425
+ return sortFindings(reported).map(formatOne).join("\n\n");
424
426
  }
425
427
  function summarize(findings) {
426
428
  const counts = { error: 0, warning: 0, info: 0 };
@@ -2453,7 +2455,7 @@ function checkForeignPragma(graph) {
2453
2455
  }
2454
2456
 
2455
2457
  // src/cli/checks/export-map.generated.ts
2456
- var EXPORT_MAP_VERSION = "5.12.0";
2458
+ var EXPORT_MAP_VERSION = "5.13.0";
2457
2459
  var ENTRY_SPECIFIERS = "vitest-auto-spy vitest-auto-spy/bun vitest-auto-spy/bun-angular vitest-auto-spy/node vitest-auto-spy/rstest vitest-auto-spy/rxjs vitest-auto-spy/console vitest-auto-spy/dom-stubs vitest-auto-spy/diagnostics vitest-auto-spy/jasmine vitest-auto-spy/jasmine-compat vitest-auto-spy/observer-spy vitest-auto-spy/angular vitest-auto-spy/angular-http vitest-auto-spy/angular-router vitest-auto-spy/signal-forms vitest-auto-spy/nestjs vitest-auto-spy/react vitest-auto-spy/vue vitest-auto-spy/svelte vitest-auto-spy/setup vitest-auto-spy/zone vitest-auto-spy/eslint-plugin";
2458
2460
  var EXPORTED_BY = {
2459
2461
  AccessorImplementations: "0 1 2 3 4 12 17 18 19",
@@ -3484,6 +3486,11 @@ Options
3484
3486
  perf only. How many times its recorded share a file has to
3485
3487
  take (2), and the absolute floor under which it is noise
3486
3488
  (500 ms).
3489
+ --min-severity <error|warning|info>
3490
+ The quietest findings the report prints. Default info, which
3491
+ prints everything. The tally line still counts what was hidden,
3492
+ and nothing about the exit code moves \u2014 a note never failed a
3493
+ run. Works for doctor and for perf.
3487
3494
  --top <n> perf only. Rows in the "slowest files" and "slowest bodies"
3488
3495
  tables. 0 turns them off. Asked for explicitly, a run whose
3489
3496
  slowest file is under the one-second floor says so rather
@@ -4709,16 +4716,22 @@ function formatPhases(phases) {
4709
4716
  const rows = phases.map((phase) => ` ${phase.name.padEnd(14)}${formatMs(phase.ms).padStart(10)}${formatShare(phase.share).padStart(9)}`);
4710
4717
  return [header2, ...rows].join("\n");
4711
4718
  }
4712
- function reportFindings(analysis, io) {
4719
+ function reportFindings(analysis, io, minSeverity) {
4713
4720
  if (analysis.findings.length === 0) {
4714
4721
  io.out(`
4715
4722
  ${nothingToDo(analysis)}`);
4716
4723
  return;
4717
4724
  }
4725
+ reportOrTally(analysis.findings, io, minSeverity);
4726
+ }
4727
+ function reportOrTally(findings, io, minSeverity) {
4728
+ const report2 = formatFindings(findings, minSeverity);
4729
+ if (report2 !== "") {
4730
+ io.out(`
4731
+ ${report2}`);
4732
+ }
4718
4733
  io.out(`
4719
- ${formatFindings(analysis.findings)}`);
4720
- io.out(`
4721
- ${summarize(analysis.findings)}`);
4734
+ ${summarize(findings)}`);
4722
4735
  }
4723
4736
  var PERF_GATE_FAILED = 1;
4724
4737
  var PERF_NO_MEASUREMENT = 2;
@@ -4771,7 +4784,7 @@ function unmatchedScope(run, cwd, only) {
4771
4784
  const paths = [...measuredFiles(run, cwd).keys()];
4772
4785
  return only.filter((entry) => !paths.some((path) => isJudged(path, [entry])));
4773
4786
  }
4774
- function runGate(run, cwd, io, gate, extra) {
4787
+ function runGate(run, cwd, io, gate, extra, minSeverity) {
4775
4788
  const unmatched = unmatchedScope(run, cwd, gate.options.only);
4776
4789
  if (unmatched.length > 0) {
4777
4790
  io.err(
@@ -4789,10 +4802,7 @@ perf gate: nothing over budget \u2014 no test body over ${formatMs(gate.options.
4789
4802
  return 0;
4790
4803
  }
4791
4804
  const verdict = gateVerdict(candidates2, confirmRun(gate, suspectFiles(candidates2), cwd, io), cwd, gate.trustSingle);
4792
- io.out(`
4793
- ${formatFindings(verdict.findings)}`);
4794
- io.out(`
4795
- ${summarize(verdict.findings)}`);
4805
+ reportOrTally(verdict.findings, io, minSeverity);
4796
4806
  return verdict.failed ? PERF_GATE_FAILED : 0;
4797
4807
  }
4798
4808
  function baselineCandidates(run, cwd, request, io) {
@@ -4868,7 +4878,7 @@ function renderPerf(source, profile, io, options = {}) {
4868
4878
  }
4869
4879
  io.out(formatPhases(analysis.phases));
4870
4880
  reportHotspots(source.run, profile.cwd, options.top, io);
4871
- reportFindings(analysis, io);
4881
+ reportFindings(analysis, io, options.minSeverity);
4872
4882
  if (options.baseline?.update === true) {
4873
4883
  recordBaseline(source.run, profile.cwd, options.baseline.path, io);
4874
4884
  return 0;
@@ -4877,7 +4887,7 @@ function renderPerf(source, profile, io, options = {}) {
4877
4887
  if (gate === void 0) {
4878
4888
  if (regressions.length > 0) {
4879
4889
  io.out(`
4880
- ${formatFindings(gateVerdict(regressions, void 0, profile.cwd, false).findings)}`);
4890
+ ${formatFindings(gateVerdict(regressions, void 0, profile.cwd, false).findings, options.minSeverity)}`);
4881
4891
  }
4882
4892
  return 0;
4883
4893
  }
@@ -4887,7 +4897,7 @@ ${formatFindings(gateVerdict(regressions, void 0, profile.cwd, false).findings)}
4887
4897
  );
4888
4898
  return PERF_NO_MEASUREMENT;
4889
4899
  }
4890
- return runGate(source.run, profile.cwd, io, gate, regressions);
4900
+ return runGate(source.run, profile.cwd, io, gate, regressions, options.minSeverity);
4891
4901
  }
4892
4902
  var ROOT_CONFIGS = [
4893
4903
  "vitest.config.ts",
@@ -5198,7 +5208,14 @@ function perfRemeasure(options, spawn = spawnProcess, packageRoot = ownPackageRo
5198
5208
 
5199
5209
  // src/cli/main.ts
5200
5210
  var STATUS_WIDTH = 10;
5201
- function doctorCommand(cwd, io) {
5211
+ function minSeverityOf(args) {
5212
+ const raw = flagValue(args, "min-severity")?.trim().toLowerCase();
5213
+ if (raw === "error" || raw === "info") {
5214
+ return raw;
5215
+ }
5216
+ return raw === "warning" || raw === "warn" ? "warning" : void 0;
5217
+ }
5218
+ function doctorCommand(cwd, argv, io) {
5202
5219
  const profile = readProfile(cwd);
5203
5220
  const findings = runDoctor(profile);
5204
5221
  io.out(`vitest-auto-spy doctor \u2014 ${cwd}`);
@@ -5208,7 +5225,10 @@ function doctorCommand(cwd, io) {
5208
5225
  io.out("No problems found.");
5209
5226
  return 0;
5210
5227
  }
5211
- io.out(formatFindings(findings));
5228
+ const report2 = formatFindings(findings, minSeverityOf(parseArgs(argv)));
5229
+ if (report2 !== "") {
5230
+ io.out(report2);
5231
+ }
5212
5232
  io.out(`
5213
5233
  ${summarize(findings)}`);
5214
5234
  return hasFailures(findings) ? 1 : 0;
@@ -5252,10 +5272,12 @@ function perfCommand(cwd, argv, io) {
5252
5272
  const gate = flagEnabled(args, "gate") ? { options: gateOptions(args), remeasure: trustSingle ? void 0 : perfRemeasure(options), trustSingle } : void 0;
5253
5273
  const baseline = baselineRequest(args, cwd);
5254
5274
  const top = flagNumber(args, "top");
5275
+ const minSeverity = minSeverityOf(args);
5255
5276
  return renderPerf(readPerfRun(options), profile, io, {
5256
5277
  ...gate === void 0 ? {} : { gate },
5257
5278
  ...baseline === void 0 ? {} : { baseline },
5258
- ...top === void 0 ? {} : { top }
5279
+ ...top === void 0 ? {} : { top },
5280
+ ...minSeverity === void 0 ? {} : { minSeverity }
5259
5281
  });
5260
5282
  }
5261
5283
  function formatAction(action) {
@@ -5318,7 +5340,7 @@ function runCli(argv, io) {
5318
5340
  return args.command === void 0 && !flagEnabled(args, "help") ? 2 : 0;
5319
5341
  }
5320
5342
  if (args.command === "doctor") {
5321
- return doctorCommand(cwd, io);
5343
+ return doctorCommand(cwd, argv, io);
5322
5344
  }
5323
5345
  if (args.command === "init") {
5324
5346
  return initCommand(cwd, argv, io);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest-auto-spy",
3
- "version": "5.12.0",
3
+ "version": "5.13.0",
4
4
  "description": "Auto-generate fully-typed test spies from a class — across Vitest, Bun, node:test and Rstest, with Angular/NestJS/React/Vue/Svelte recipes. Drop-in replacement for jest-auto-spies and jasmine-auto-spies.",
5
5
  "keywords": [
6
6
  "auto-mock",