sumlyzer 0.4.0 → 0.5.1

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.
package/README.md CHANGED
@@ -11,9 +11,14 @@
11
11
  <a href="./LICENSE"><img src="https://img.shields.io/npm/l/sumlyzer.svg" alt="license" /></a>
12
12
  </p>
13
13
 
14
- Run every npm workspace's test script, one by one. Passing workspaces output
15
- to a single line; failing ones print only the relevant failure detail.
16
- Ends with an aggregated pass/fail summary table, so nothing scrolls out of the terminal.
14
+ `npm run test --workspaces --if-present` runs every workspace, but gives you no
15
+ aggregated summary and no way to fail fast — an early failure just scrolls off
16
+ screen once later workspaces print their own output.
17
+
18
+ Sumlyzer runs each workspace's test script, one by one or concurrently.
19
+ Passing workspaces collapse to a single line, failing ones print just the
20
+ relevant failure detail, and everything ends with an aggregated pass/fail
21
+ summary table so nothing scrolls out of the terminal.
17
22
 
18
23
  ## Requirements
19
24
 
@@ -55,8 +60,8 @@ Options:
55
60
 
56
61
  Exit code is `1` if any workspace fails (or if the project has no
57
62
  workspaces), `0` otherwise, wire it straight into CI without extra parsing.
58
- This also applies when `--junit` can't write its report (e.g. an invalid
59
- `<path>`): the exit code is `1` even if every workspace's tests passed.
63
+ This also applies when `--junit` can't write its report.
64
+ The exit code is `1` even if every workspace's tests passed.
60
65
 
61
66
  ## Features
62
67
 
@@ -68,6 +73,11 @@ This also applies when `--junit` can't write its report (e.g. an invalid
68
73
  - Concurrent runs (`--concurrency <n>`): run several workspaces' test scripts
69
74
  at once instead of one by one
70
75
 
76
+ ## Roadmap
77
+
78
+ - **Watch mode**: walking the workspace dependency graph (topological sort) so a change in
79
+ one workspace also re-runs the workspaces that depend on it.
80
+
71
81
  ## Example
72
82
 
73
83
  ```
@@ -77,49 +87,42 @@ running scanner
77
87
  ✓ scanner 10.1s (161/162 tests)
78
88
  running tarball
79
89
  ✓ tarball 1.8s (77/77 tests)
80
- running mama
81
- ✓ mama 1.2s (85/85 tests)
82
90
  running tree-walker
83
91
  ✓ tree-walker 3.0s (26/26 tests)
84
- running conformance
85
- ✓ conformance 1.1s (35/35 tests)
86
- running i18n
87
- ✓ i18n 1.1s (19/19 tests)
88
- running rc
89
- ✓ rc 4.1s (28/28 tests)
90
- running utils
91
- ✓ utils 1.1s (30/30 tests)
92
92
  running flags
93
93
  ✓ flags 1.1s (9/9 tests)
94
- running fs-walk
95
- ✓ fs-walk 1.1s (3/3 tests)
96
- running github
97
- ✓ github 2.9s (8/8 tests)
98
- running gitlab
99
- ✓ gitlab 4.3s (8/8 tests)
100
94
 
101
95
  Summary
102
- ┌─────────┬────────────────┬──────────┬────────────┬────────────────┬─────────┬────────┬────────┐
103
- │ (index) │ workspace │ status │ duration │ testsDuration │ tests │ pass │ fail │
104
- ├─────────┼────────────────┼──────────┼────────────┼────────────────┼─────────┼────────┼────────┤
105
- │ 0 │ 'contact' │ 'PASS' │ '2.6s' │ '0.9s' │ '35' │ '35' │ '0' │
106
- │ 1 │ 'scanner' │ 'PASS' │ '10.1s' │ '8.7s' │ '162' │ '161' │ '0' │
107
- │ 2 │ 'tarball' │ 'PASS' │ '1.8s' │ '0.7s' │ '77' │ '77' │ '0' │
108
- │ 3 │ 'mama' │ 'PASS' │ '1.2s' │ '0.1s' │ '85' │ '85' │ '0' │
109
- │ 4 │ 'tree-walker' │ 'PASS' │ '3.0s' │ '2.0s' │ '26' │ '26' │ '0' │
110
- │ 5 │ 'conformance' │ 'PASS' │ '1.1s' │ '0.1s' │ '35' │ '35' │ '0' │
111
- │ 6 │ 'i18n' │ 'PASS' │ '1.1s' │ '0.2s' │ '19' │ '19' │ '0' │
112
- │ 7 │ 'rc' │ 'PASS' │ '4.1s' │ '0.6s' │ '28' │ '28' │ '0' │
113
- │ 8 │ 'utils' │ 'PASS' │ '1.1s' │ '0.1s' │ '30' │ '30' │ '0' │
114
- │ 9 │ 'flags' │ 'PASS' │ '1.1s' │ '0.1s' │ '9' │ '9' │ '0' │
115
- │ 10 │ 'fs-walk' │ 'PASS' │ '1.1s' │ '0.1s' │ '3' │ '3' │ '0' │
116
- │ 11 │ 'github' │ 'PASS' │ '2.9s' │ '2.0s' │ '8' │ '8' │ '0' │
117
- │ 12 │ 'gitlab' │ 'PASS' │ '4.3s' │ '3.3s' │ '8' │ '8' │ '0' │
118
- └─────────┴────────────────┴──────────┴────────────┴────────────────┴─────────┴────────┴────────┘
119
-
120
- 13/13 workspaces passed.
96
+ ┌─────────────┬────────┬──────────┬───────────────┬───────┬───────┬──────┬──────┬──────┬───────────┐
97
+ │ (index) │ status │ duration │ testsDuration │ tests │ pass │ fail │ skip │ todo │ cancelled │
98
+ ├─────────────┼────────┼──────────┼───────────────┼───────┼───────┼──────┼──────┼──────┼───────────┤
99
+ │ contact │ 'PASS' │ '2.6s' │ '0.9s' │ '35' │ '35' │ '0' │ '0' │ '0' │ '0' │
100
+ │ scanner │ 'PASS' │ '10.1s' │ '8.7s' │ '162' │ '161' │ '0' │ '1' │ '0' │ '0' │
101
+ │ tarball │ 'PASS' │ '1.8s' │ '0.7s' │ '77' │ '77' │ '0' │ '0' │ '0' │ '0' │
102
+ │ tree-walker │ 'PASS' │ '3.0s' │ '2.0s' │ '26' │ '26' │ '0' │ '0' │ '0' │ '0' │
103
+ │ flags │ 'PASS' │ '1.1s' │ '0.1s' │ '9' │ '9' │ '0' │ '0' │ '0' │ '0' │
104
+ └─────────────┴────────┴──────────┴───────────────┴───────┴───────┴──────┴──────┴──────┴───────────┘
105
+
106
+ 5/5 workspaces passed.
121
107
  ```
122
108
 
109
+ ### Summary columns
110
+
111
+ | Column | Meaning |
112
+ | --------------- | ------------------------------------------------------------------------------------------------ |
113
+ | `(index)` | Workspace name — `console.table` is fed an object keyed by workspace name (via `workspaceName` in [reporter.mjs](./src/reporter.mjs)) instead of an array, so this column carries the name instead of a meaningless row number |
114
+ | `status` | `PASS`, `FAIL`, or `SKIPPED` (only reached when `--ff` stopped scheduling before this workspace ran) |
115
+ | `duration` | Wall-clock time for the whole `npm run <script> --workspace=<path>` process, including npm/spawn overhead |
116
+ | `testsDuration` | `duration_ms` as reported by node's own test runner — the actual test execution time, without the npm overhead |
117
+ | `tests` | Total number of tests node:test ran in that workspace |
118
+ | `pass` | Number of passing tests |
119
+ | `fail` | Number of failing tests |
120
+ | `skip` | Tests reported as skipped (`ℹ skipped`), e.g. `t.skip()` or `{ skip: true }` |
121
+ | `todo` | Tests reported as todo (`ℹ todo`), e.g. `t.todo()` — intentionally not implemented yet, distinct from `skip` |
122
+ | `cancelled` | Tests reported as cancelled (`ℹ cancelled`), e.g. a timeout or a parent suite/hook failure that aborted them — unlike `skip`/`todo` this usually signals a real problem |
123
+
124
+ `duration` and `testsDuration` are deliberately both shown: a gap between them usually means npm/process startup overhead rather than slow tests. `tests` always equals `pass + fail + skip + todo + cancelled`; the last three columns exist so none of those buckets can hide silently behind an all-green `pass`/`fail` pair.
125
+
123
126
  ### On failure
124
127
 
125
128
  Only the failing workspace prints its detail and passing ones stay collapsed to a single line.
@@ -146,14 +149,14 @@ running flags
146
149
  ✓ flags 1.1s (9/9 tests)
147
150
 
148
151
  Summary
149
- ┌─────────┬────────────┬──────────┬────────────┬────────────────┬─────────┬────────┬────────┐
150
- │ (index) │ workspace │ status │ duration │ testsDuration │ tests │ pass │ fail │
151
- ├─────────┼────────────┼──────────┼────────────┼────────────────┼─────────┼────────┼────────┤
152
- │ 0 │ 'contact' │ 'PASS' │ '2.6s' │ '0.9s' │ '35' │ '35' │ '0' │
153
- │ 1 │ 'scanner' │ 'PASS' │ '10.1s' │ '8.7s' │ '162' │ '161' │ '0' │
154
- │ 2 │ 'utils' │ 'FAIL' │ '1.3s' │ '0.1s' │ '30' │ '29' │ '1' │
155
- │ 3 │ 'flags' │ 'PASS' │ '1.1s' │ '0.1s' │ '9' │ '9' │ '0' │
156
- └─────────┴────────────┴──────────┴────────────┴────────────────┴─────────┴────────┴────────┘
152
+ ┌─────────┬────────┬──────────┬───────────────┬───────┬───────┬──────┬──────┬──────┬───────────┐
153
+ │ (index) │ status │ duration │ testsDuration │ tests │ pass │ fail │ skip │ todo │ cancelled │
154
+ ├─────────┼────────┼──────────┼───────────────┼───────┼───────┼──────┼──────┼──────┼───────────┤
155
+ │ contact │ 'PASS' │ '2.6s' │ '0.9s' │ '35' │ '35' │ '0' │ '0' │ '0' │ '0' │
156
+ │ scanner │ 'PASS' │ '10.1s' │ '8.7s' │ '162' │ '161' │ '0' │ '1' │ '0' │ '0' │
157
+ │ utils │ 'FAIL' │ '1.3s' │ '0.1s' │ '30' │ '29' │ '1' │ '0' │ '0' │ '0' │
158
+ │ flags │ 'PASS' │ '1.1s' │ '0.1s' │ '9' │ '9' │ '0' │ '0' │ '0' │ '0' │
159
+ └─────────┴────────┴──────────┴───────────────┴───────┴───────┴──────┴──────┴──────┴───────────┘
157
160
 
158
161
  1/4 workspace(s) failed:
159
162
  utils
@@ -215,19 +218,15 @@ With `--ff`, a failure only stops workspaces that haven't started yet; any
215
218
  workspace already running when the failure is detected runs to completion
216
219
  (sumlyzer doesn't kill in-flight processes).
217
220
 
221
+ ![Concurrent run stopping early on failure](https://github.com/ErwanRaulo/sumlyzer/blob/main/concurrency-failed.png?raw=true)
222
+
218
223
  ## Why
219
224
 
220
- `npm run test --workspaces --if-present` runs every workspace but gives you
221
- no aggregated summary and no way to fail fast early. An early failure just
222
- scrolls off screen once later workspaces print their own output. sumlyzer is
223
- a small, dependency-free tool that solves just this.
224
-
225
- This exact fail-fast behavior at the `--workspaces` level has been requested
226
- from npm more than once:
227
- [npm/rfcs#575](https://github.com/npm/rfcs/issues/575) (open) and
228
- [npm/rfcs#602](https://github.com/npm/rfcs/issues/602) (closed). Until it
229
- lands (if it ever does), sumlyzer's `--ff` flag gets you there — see also
230
- this [Stack Overflow answer](https://stackoverflow.com/questions/71300870/npm-workspace-command-does-not-stop-executing-when-command-fails-for-a-workspace/79989284#79989284)
225
+ This fail-fast behavior at the `--workspaces` level has been requested from
226
+ npm more than once: [npm/rfcs#575](https://github.com/npm/rfcs/issues/575)
227
+ (open) and [npm/rfcs#602](https://github.com/npm/rfcs/issues/602) (closed).
228
+ Until it lands, sumlyzer's `--ff` flag gets you there — see also this
229
+ [Stack Overflow answer](https://stackoverflow.com/questions/71300870/npm-workspace-command-does-not-stop-executing-when-command-fails-for-a-workspace/79989284#79989284)
231
230
  on the same problem.
232
231
 
233
232
  ## Contributing
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sumlyzer",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "description": "Run every npm workspace's test script, only show output for the ones that fail, and finish with an aggregated pass/fail summary.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,6 +1,8 @@
1
1
  const COUNT_INDEX = 1;
2
2
  const count = (target, output) => new RegExp(String.raw`ℹ ${target} (\d+)`).exec(output)?.[COUNT_INDEX];
3
3
 
4
+ // skip/todo/cancelled fall back to "0" rather than "?": unlike pass/fail, a missing
5
+ // line here is far more likely to mean "zero" than "parsing went wrong somehow".
4
6
  export function parseTestCounts(output) {
5
7
  const tests = count("tests", output);
6
8
 
@@ -12,6 +14,9 @@ export function parseTestCounts(output) {
12
14
  tests,
13
15
  pass: count("pass", output) ?? "?",
14
16
  fail: count("fail", output) ?? "?",
17
+ skip: count("skipped", output) ?? "0",
18
+ todo: count("todo", output) ?? "0",
19
+ cancelled: count("cancelled", output) ?? "0",
15
20
  durationMs: count("duration_ms", output)
16
21
  };
17
22
  }
package/src/reporter.mjs CHANGED
@@ -57,32 +57,32 @@ export function printWorkspaceResult(name, result, ciGroup) {
57
57
  process.stdout.write(red(`✗ ${name}`) + dim(` ${seconds}, exit code ${result.exitCode}\n\n`));
58
58
  }
59
59
 
60
- function summaryRow(workspace, status, duration, counts) {
60
+ function summaryRow(status, duration, counts) {
61
61
  return {
62
- workspace,
63
62
  status,
64
63
  duration,
65
64
  testsDuration: counts?.durationMs ? formatSeconds(Number(counts.durationMs)) : "-",
66
65
  tests: counts?.tests ?? "-",
67
66
  pass: counts?.pass ?? "-",
68
- fail: counts?.fail ?? "-"
67
+ fail: counts?.fail ?? "-",
68
+ skip: counts?.skip ?? "-",
69
+ todo: counts?.todo ?? "-",
70
+ cancelled: counts?.cancelled ?? "-"
69
71
  };
70
72
  }
71
73
 
72
74
  export function printSummary(results, skipped) {
73
75
  console.log(bold("\nSummary"));
74
- console.table([
75
- ...results.map(({ wsPath, exitCode, durationMs, counts }) => {
76
-
77
- return summaryRow(
78
- workspaceName(wsPath),
79
- exitCode === 0 ? "PASS" : "FAIL",
80
- formatSeconds(durationMs),
81
- counts
82
- );
83
- }),
84
- ...skipped.map((wsPath) => summaryRow(workspaceName(wsPath), "SKIPPED", "-", null))
85
- ]);
76
+
77
+ const rows = {};
78
+ for (const { wsPath, exitCode, durationMs, counts } of results) {
79
+ rows[workspaceName(wsPath)] = summaryRow(exitCode === 0 ? "PASS" : "FAIL", formatSeconds(durationMs), counts);
80
+ }
81
+ for (const wsPath of skipped) {
82
+ rows[workspaceName(wsPath)] = summaryRow("SKIPPED", "-", null);
83
+ }
84
+
85
+ console.table(rows);
86
86
 
87
87
  if (skipped.length > 0) {
88
88
  console.log(dim(`${skipped.length} workspace(s) skipped (--ff): ${skipped.map(workspaceName).join(", ")}`));