Skip to content

test: let an execution test say which errors its build reports - #1769

Merged
johnnyreilly merged 5 commits into
nextfrom
ccr-1e84ebc8-9fkzwk
Dec 2, 2026
Merged

johnnyreilly merged 5 commits into
nextfrom
ccr-1e84ebc8-9fkzwk

Conversation

@johnnyreilly

@johnnyreilly johnnyreilly commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #1767. Every execution test had to build cleanly, so nothing in this pack checked that an error is reported. The comparison tests do, but by comparing webpack's printed output, which pins them to one version of webpack and of TypeScript. This lets an execution test say which errors its build reports, in a form that holds on every version in the CI matrix.

How a test says it

A test with an expectedErrors.json passes if its build reports exactly the errors listed: no more and no fewer, in any order.

{
  "errors": [
    { "code": "TS2322", "file": "src/app.ts", "line": 3, "column": 1 },
    { "message": "Module parse failed", "file": "src/app.ts" }
  ],
  "warnings": [],
  "transpileOnly": {
    "errors": []
  }
}
  • An entry gives a TypeScript error code, a file, a line and a column, or text the message contains. It needs a code or a message; the rest is as strict as the test wants.
  • "message" is for errors with no code: ts-loader's own (an unknown loader option, a .ts file in node_modules) and webpack's (Module parse failed).
  • "warnings" lists the build's warnings in the same form. Without it they aren't checked.
  • The test runs with and without transpileOnly, like a test with specs. "transpileOnly" lists what that build reports when it differs; without it, the same is expected of both.
  • The test is built with its own webpack.config.js, into a temporary folder, and has no spec files.

A failing test prints what was listed but not reported, what was reported but not listed, and all the build's errors in the file's own form. So a new test starts as { "errors": [] } and is filled in from that output.

An invalid expectedErrors.json, or one beside spec files, fails the test with a message saying why.

Tests added

Eight cases ported from the comparison tests, under the same names. Each has the same expectedErrors.json on every version.

Test What it checks
errors a syntax error, in both modes, and webpack's parse error after it
dependencyErrors type errors from two imported files; none with transpileOnly; no warnings
tsconfigInvalid two invalid options in tsconfig.json, and the loader's own error
compilerOptionsErrors a removed compiler option (baseUrl)
ignoreDiagnostics the ignored code isn't reported and the other is
reportFiles an error in an excluded file isn't reported
nodeModulesMeaningfulErrorWhenImportingTs ts-loader's message for a .ts file in node_modules; none with transpileOnly
validateLoaderOptionNames ts-loader's message for an unknown option

The comparison tests they come from stay: those still cover the formatted output, and watch mode.

Things to know when reviewing

  • A change from the sketch I gave before: "transpileOnly" is an object with "errors" (and optionally "warnings"), not a bare list, so that mode can have its own warnings too.
  • Columns start at 1, as tsc and ts-loader's own app.ts(3,1) print them. webpack's are one less.
  • webpack's own errors have no line or column in this form: theirs are positions in the compiled code, which would not hold across TypeScript versions.
  • setTranspileOnly moved out of run-specs.js into its own file, as both runners use it. No other change to how existing tests run.
  • The commit list shows test: run the execution tests in parallel, in both modes, with nothing installed per test #1767's three commits and a merge. That merge changes no file. The branch was restarted from next under the same name, and I joined its earlier, already merged history to it when a push was refused. As it turned out the remote branch had been deleted, so the merge wasn't needed. A squash merge drops it.
  • test: comparison test housekeeping (test.json settings, shared transpile snapshots, readable bundles, one CI workflow) #1768 currently conflicts with next in six files (AGENTS.md, package.json, the lockfile, the build action, the execution-tests workflow and test/execution-tests/run-tests.js), with or without this PR. Of those this PR touches two: AGENTS.md, where it adds one paragraph, and run-tests.js, where it changes getSuites.

Verified

  • All 65 suites pass locally on webpack 5 with TypeScript 7.1.0-beta and with next (7.1.0-dev.20261201.1), and 62 on webpack 4 (three tests need webpack 5), with the same expectedErrors.json files throughout.
  • A wrong line, a missing error, an unlisted error, an unlisted warning, an unknown property, and spec files beside expectedErrors.json each fail the test, with the message shown above.
  • lint, check:execution-tests, knip and format:check pass.
  • CI on this PR: all 36 execution-test jobs pass (Ubuntu, macOS and Windows; Node 22, 24 and 26; TypeScript 7.1.0-beta and next; webpack 4 and 5), so the file paths in expectedErrors.json hold on Windows and macOS too. The comparison tests, lint, format and knip pass.

https://claude.ai/code/session_01Q2Jv7JfjPgPbdEeruRgEue


Generated by Claude Code

…g installed per test

The pack's own work took about 15 seconds, but every run installed
dependencies for ten of its tests first. On Windows CI that was most of the
test step, and `npm ci` was most of the rest of the job.

Dependencies
- No test has a package.json any more. react, react-dom, their types and
  tslib are devDependencies of ts-loader, like jasmine and Babel already were.
- date-fns, event-rank and chalk are replaced by small stand-in packages
  tracked in each test's node_modules. The file: dependencies that were
  already tracked there are no longer also installed, and test/testPackages
  is gone.
- The pnpm test still runs `pnpm install`, with pnpm as a pinned
  devDependency instead of `npm install -g pnpm` on every run.

Harness
- Suites run several at a time, each in its own process, printing only a
  failing suite's output; a suite still running after 5 minutes is stopped.
- Each test with specs also runs with transpileOnly, as the comparison tests
  do. Four tests needed an outDir and rootDir for that.
- The spec files are the build's entry, so main.js is gone, and with it the
  walk through node_modules that require.context did. The entry and output
  settings that run-specs.js never read are removed from the configs.
- Nothing is written to the test folders (optionsCaching built its bundle
  there), so the scripts no longer run `git clean -xfd`, which deleted a new
  test that was not yet staged. `npm run clean` now only removes ignored files.
- `npm test` passes its arguments on as they are: a --match-test regex with
  `(` or `|` used to be a shell syntax error. It also runs the execution
  tests when the comparison tests fail.

CI
- One job with the OS in the matrix (same job names), a 15 minute timeout,
  and no fail-fast.
- typescript and webpack 4 are installed in one `npm install`.
- The execution tests build in the checkout on Windows, not a copy in
  C:\source.
- On Windows the build action caches node_modules itself.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q2Jv7JfjPgPbdEeruRgEue
react, react-dom, their types, tslib and pnpm used to be in the execution
tests' own package.json files, which Renovate's config:base preset ignores
(anything under a test folder). As root devDependencies they are now
upgraded like any other, so without a rule each would get a pull request
of its own.

- Their minor and patch upgrades come as one pull request (with
  vue-loader's, the comparison tests' equivalent).
- A major upgrade of React and its types comes as one pull request.

Nothing is blocked. The React tests pass as they are on React 19.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q2Jv7JfjPgPbdEeruRgEue
react, react-dom and their types became root devDependencies on ^18.3.1,
so Renovate's first pull request for them would have been React 19. The
tests need no change for it, so take it now. The pnpm test, which pins its
own copy, moves to the same version.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q2Jv7JfjPgPbdEeruRgEue
Every execution test had to build cleanly, so nothing checked that an error
is reported. The comparison tests do, but by comparing webpack's printed
output, which pins them to one version of webpack and of TypeScript. The
execution tests run on every version in the CI matrix.

A test with an expectedErrors.json passes if its build reports exactly the
errors listed: each by TypeScript error code, file, line and column, or by
text its message contains, for the errors of ts-loader and webpack that
have no code. Those are the same on webpack 4 and 5, and on TypeScript
7.1.0-beta and next.

- "warnings" lists the build's warnings in the same form; without it they
  are not checked.
- The test runs with and without transpileOnly, as tests with specs do.
  "transpileOnly" lists what that build reports when it differs.
- A failing test prints what was listed but not reported, what was
  reported but not listed, and the build's errors in the file's own form.
- An invalid expectedErrors.json, or one beside spec files, fails the test.

Eight cases are ported from the comparison tests, under the same names:
errors, dependencyErrors, tsconfigInvalid, compilerOptionsErrors,
ignoreDiagnostics, reportFiles, nodeModulesMeaningfulErrorWhenImportingTs
and validateLoaderOptionNames.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q2Jv7JfjPgPbdEeruRgEue
Its content is what next already has, so this changes no file: it only lets
the branch be pushed without rewriting what is on the remote.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q2Jv7JfjPgPbdEeruRgEue
@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown

Benchmark (Ubuntu)

Scenario transpileOnly PR branch median (ms) base branch median (ms) Δ vs base branch
Cold build false 466.9 473.7 -1.4%
Incremental rebuild (leaf touch) false 39.8 39.8 +0.1%
Incremental rebuild (hub touch) false 159.4 159.7 -0.2%
Cold build true 285.1 286.8 -0.6%
Incremental rebuild (leaf touch) true 26.7 26.3 +1.4%
Incremental rebuild (hub touch) true 27.3 27.5 -0.7%
Cold build (all orphan files) false 520.3 523.1 -0.5%
Incremental rebuild (hub touch, all orphan files) false 182.3 182.9 -0.3%
Cold build (declaration) false 527.2 528.0 -0.2%
Incremental rebuild (leaf touch, declaration) false 79.8 79.2 +0.8%

PR branch = 6d897d3 merged into next, base branch = next at 97991c1. Each row is the median of up to 60 cold builds, or up to 200 rebuilds, after 2 warmup iterations. Report-only - no threshold fails this check.

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown

Benchmark (Windows)

Scenario transpileOnly PR branch median (ms) base branch median (ms) Δ vs base branch
Cold build false 796.3 805.3 -1.1%
Incremental rebuild (leaf touch) false 57.2 55.9 +2.4%
Incremental rebuild (hub touch) false 245.7 242.8 +1.2%
Cold build true 466.0 472.3 -1.3%
Incremental rebuild (leaf touch) true 36.7 33.1 +10.8%
Incremental rebuild (hub touch) true 35.7 35.5 +0.5%
Cold build (all orphan files) false 903.5 910.3 -0.7%
Incremental rebuild (hub touch, all orphan files) false 315.0 308.8 +2.0%
Cold build (declaration) false 982.4 958.2 +2.5%
Incremental rebuild (leaf touch, declaration) false 411.5 405.9 +1.4%

PR branch = 6d897d3 merged into next, base branch = next at 97991c1. Each row is the median of up to 60 cold builds, or up to 200 rebuilds, after 2 warmup iterations. Report-only - no threshold fails this check.

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown

Benchmark (macOS)

Scenario transpileOnly PR branch median (ms) base branch median (ms) Δ vs base branch
Cold build false 710.6 754.3 -5.8%
Incremental rebuild (leaf touch) false 85.9 86.5 -0.8%
Incremental rebuild (hub touch) false 227.9 244.0 -6.6%
Cold build true 440.0 438.6 +0.3%
Incremental rebuild (leaf touch) true 55.0 57.3 -4.0%
Incremental rebuild (hub touch) true 55.5 56.8 -2.2%
Cold build (all orphan files) false 786.3 775.5 +1.4%
Incremental rebuild (hub touch, all orphan files) false 288.9 285.6 +1.2%
Cold build (declaration) false 782.8 779.2 +0.5%
Incremental rebuild (leaf touch, declaration) false 136.3 126.4 +7.8%

PR branch = 6d897d3 merged into next, base branch = next at 97991c1. Each row is the median of up to 60 cold builds, or up to 200 rebuilds, after 2 warmup iterations. Report-only - no threshold fails this check.

@johnnyreilly
johnnyreilly merged commit 24281ee into next Dec 2, 2026
45 checks passed
@johnnyreilly
johnnyreilly deleted the ccr-1e84ebc8-9fkzwk branch December 2, 2026 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants