Skip to content

test: fold the suites onto the option each one covers - #725

Merged
alexander-akait merged 3 commits into
mainfrom
test/consolidate-suites
Sep 5, 2026
Merged

test: fold the suites onto the option each one covers#725
alexander-akait merged 3 commits into
mainfrom
test/consolidate-suites

Conversation

@alexander-akait

Copy link
Copy Markdown
Member

Summary

test/ had grown a file per situation rather than per option — css-minify-option, swc-html-minify-option and image-minify-option were all the minify option; terserOptions-option is its own deprecated alias; generate-watch and generate-filesystem-cache were generate seen from two angles. Twenty-four files become thirteen, with each one named for the option it covers.

The reason this is worth more than tidiness is the gating. Five of those files were skipped whole by testPathIgnorePatterns wherever their packages or webpack version were missing, so on the legacy Node rows and on Windows every case in them disappeared — including the ones needing nothing special. test/helpers/env.js now holds those environment facts as one source of truth, jest.config.js reads it for whole-file skips and a merged file reads it to skip only the blocks that need more. One whole-file skip is left where it is genuinely unavoidable: embedded-source requires a deep webpack path at module scope that ships from 5.110, so it throws before any describe runs.

getEcmaVersion loses its unit test and gains nineteen build-driven cases instead, reading back the ecma a recording minimizer actually received — which tests the wiring rather than the lookup.

No test was deleted, rewritten or skipped: 573 cases and 825 snapshots before and after.

What kind of change does this PR introduce?

test

Did you add tests for your changes?

This is only tests — moved, not added, apart from getEcmaVersion's cases becoming builds. Snapshots moved with their tests and were re-keyed for the added describe level (61 keys), verified with --ci so nothing could be silently rewritten and nothing is reported obsolete.

Does this PR introduce a breaking change?

No — no source change.

If relevant, what needs to be documented once your changes are merged or what have you already documented?

n/a — test/helpers/env.js documents each gate next to the flag it sets, which is where a contributor adding a suite will look.

Use of AI

Claude Code did the consolidation. It checked what actually blocked each merge rather than moving text: embedded-source's module-scope require is why that one file keeps its whole-file skip and why embedded-protocol could not join it, and image-minify-option was confirmed to reach its packages only inside test bodies, which is what made per-block gating safe there. Two mistakes it made are worth knowing, since both would have passed review while testing nothing: the first getEcmaVersion build returned ecma: undefined because the recording minimizer ran in a worker, and the flags had to be set explicitly false because webpack fills unset ones from the target defaults and would otherwise raise the answer behind the assertion.


🤖 Generated with Claude Code

https://claude.ai/code/session_016TQeNpahUSDUjD2Crugy5H


Generated by Claude Code

Twenty-four files for seventeen subjects: `generate` was spread over three,
`minify` over three, `minimizerOptions` over two, and `imagemin` over two.
Each option now has one file -- watch, the filesystem cache and
`imageminGenerate` join `generate`, css and swc-html join `minify`,
`terserOptions` joins the alias it is deprecated for, and
`imageminNormalizeConfig` joins the minimizer that calls it. The helpers
those files each carried a copy of are now written once.

Merging needed the environment gate to move first. Four of them were skipped
whole by `testPathIgnorePatterns`, so folding one into a file that runs
everywhere would have taken it to Node 10 and to Windows, where its
minimizers do not install. `test/helpers/env.js` now holds what this
environment can run as one answer: `jest.config.js` reads it to skip a whole
file, and a merged file reads it to skip only the block that needs more.
Two files still need the whole-file kind, both because they reach for what
they need at module scope.

`getEcmaVersion` is covered by builds now rather than by calling it: each
case sets `output.environment` and reads back the `ecma` that reached the
minimizer, which is the wiring the option is for. Every flag is stated false
first, since webpack fills an unset one from the target and would raise the
answer behind the case; and the minimizer runs in process, or the recording
happens in a worker and never comes back.

Snapshots moved with their tests and were re-keyed for the describe level the
gating adds. Same 573 tests, same 825 snapshots.
The image minimizers, the query in an asset name and what identifies a
minimizer to the cache are all the `minify` option: which assets it is
offered and what it does with them. They join it, and the worker joins
`parallel`, which is the option that decides whether there is one.

That leaves one whole-file skip instead of two. The image file was skipped
wholesale where `sharp` and friends are absent; nothing in it reaches them
at module scope, so it is gated on its block instead and every other case in
`minify-option` now runs on the legacy rows too. Only `embedded-source` is
still skipped whole, because it requires a deep webpack path at module scope
that ships from 5.110.

Thirteen files where there were twenty-four, same 573 tests and 825
snapshots. `minify-option` carries 157 of them, which is the cost of the
option being this large a subject.
@changeset-bot

changeset-bot Bot commented Sep 5, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 5194a6e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@codecov

codecov Bot commented Sep 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.91%. Comparing base (db39bf9) to head (5194a6e).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #725   +/-   ##
=======================================
  Coverage   94.91%   94.91%           
=======================================
  Files           4        4           
  Lines        1120     1120           
  Branches      391      397    +6     
=======================================
  Hits         1063     1063           
  Misses         50       50           
  Partials        7        7           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

CI caught what local runs could not: on Node 20 every test passed and the
job still failed, with 51 obsolete snapshots. A snapshot belonging to a
block skipped inside a file that still runs has no test to match, so jest
reports it obsolete, and the rows from Node 20 up pass `--ci` without the
`-u` that quietly prunes it on the older ones. A whole-file skip never had
the problem because the pack was not read at all.

So the CSS, swc-html and image suites go back to their own files and their
own file-level skips, and `jest.config.js` says why. What stays merged is
what takes no snapshot: the watch and filesystem-cache cases on `generate`,
`imageminGenerate` beside the generator it belongs to, `terserOptions` on
the option it is an alias of, the worker on `parallel`, and the query and
version cases on `minify`. `imageminNormalizeConfig` joins the image file,
which shares its gate.

Sixteen files rather than thirteen, and the block-level gate is kept only
where it is sound. Verified by forcing each gate off and re-running: 553
then 389 tests, no obsolete snapshot either time.
@alexander-akait
alexander-akait merged commit a27c7fd into main Sep 5, 2026
31 checks passed
@alexander-akait
alexander-akait deleted the test/consolidate-suites branch September 5, 2026 12:39
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.

1 participant