Repository navigation
test: let an execution test say which errors its build reports - #1769
Merged
Merged
Conversation
…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
Benchmark (Ubuntu)
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. |
Benchmark (Windows)
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. |
Benchmark (macOS)
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.jsonpasses 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": [] } }"message"is for errors with no code: ts-loader's own (an unknown loader option, a.tsfile innode_modules) and webpack's (Module parse failed)."warnings"lists the build's warnings in the same form. Without it they aren't checked.transpileOnly, like a test with specs."transpileOnly"lists what that build reports when it differs; without it, the same is expected of both.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.jsonon every version.errorsdependencyErrorstranspileOnly; no warningstsconfigInvalidtsconfig.json, and the loader's own errorcompilerOptionsErrorsbaseUrl)ignoreDiagnosticsreportFilesnodeModulesMeaningfulErrorWhenImportingTs.tsfile innode_modules; none withtranspileOnlyvalidateLoaderOptionNamesThe comparison tests they come from stay: those still cover the formatted output, and watch mode.
Things to know when reviewing
"transpileOnly"is an object with"errors"(and optionally"warnings"), not a bare list, so that mode can have its own warnings too.tscand ts-loader's ownapp.ts(3,1)print them. webpack's are one less.setTranspileOnlymoved out ofrun-specs.jsinto its own file, as both runners use it. No other change to how existing tests run.nextunder 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.nextin six files (AGENTS.md,package.json, the lockfile, the build action, the execution-tests workflow andtest/execution-tests/run-tests.js), with or without this PR. Of those this PR touches two:AGENTS.md, where it adds one paragraph, andrun-tests.js, where it changesgetSuites.Verified
next(7.1.0-dev.20261201.1), and 62 on webpack 4 (three tests need webpack 5), with the sameexpectedErrors.jsonfiles throughout.expectedErrors.jsoneach fail the test, with the message shown above.lint,check:execution-tests,knipandformat:checkpass.next; webpack 4 and 5), so the file paths inexpectedErrors.jsonhold on Windows and macOS too. The comparison tests, lint, format and knip pass.https://claude.ai/code/session_01Q2Jv7JfjPgPbdEeruRgEue
Generated by Claude Code