Skip to content

test: cover generatorOptions and the rename under watch - #721

Merged
alexander-akait merged 1 commit into
mainfrom
test/generate-option-coverage
Sep 5, 2026
Merged

test: cover generatorOptions and the rename under watch#721
alexander-akait merged 1 commit into
mainfrom
test/generate-option-coverage

Conversation

@alexander-akait

Copy link
Copy Markdown
Member

Summary

generatorOptions had no test at all — zero occurrences under test/ — so nothing held the array-positional and shared-object contracts it borrows from minimizerOptions, nor the ecma the plugin overlays onto it. Nothing exercised watch mode either: .watch( did not appear anywhere in test/.

Worth knowing when reading the diff: the three existing generate option cases self-skip on the webpack this repo locks, because NormalModule.processResult is a SyncWaterfallHook in every published webpack. Making their guard throw shows all three returning early. They were verified against webpack main, which carries the awaitable hook, with the guard made fatal — 11/11 pass there, and 17/17 with the cases added here.

What kind of change does this PR introduce?

test

Did you add tests for your changes?

Yes — that is the change. Four generatorOptions cases in test/generate-option.test.js, and test/generate-watch.test.js: changing the image re-runs the generator and re-emits the renamed asset, while changing only the module that imports it keeps the rename with the generator still at one call — which is the evidence that buildInfo.assetResource carried it rather than it being reapplied. Both need a cache, since production leaves caching off and every watch build then rebuilds every module.

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?

Documented here, limited to what these tests pin down: that one generatorOptions object is reused across an array of generators, that ecma and module are filled in only when the options leave them unset, and what watch mode does with a rename.

Use of AI

Claude Code wrote these. It established the two gaps by measurement rather than by reading — making the skip guard throw to show the existing cases never run, and grepping test/ for generatorOptions and for watch usage — then verified every case against a webpack that has the awaitable hook, with the guard fatal so nothing could pass by skipping. The watch test's first version asserted a claim that was false under the repo's default config, which is how the missing cache came to light.


🤖 Generated with Claude Code

https://claude.ai/code/session_016TQeNpahUSDUjD2Crugy5H


Generated by Claude Code

@changeset-bot

changeset-bot Bot commented Sep 4, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 15e5839

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 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.91%. Comparing base (5342acc) to head (15e5839).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #721   +/-   ##
=======================================
  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.

`generatorOptions` had no test at all -- zero occurrences under `test/` --
so nothing held the array-positional and shared-object contracts it borrows
from `minimizerOptions`, nor the `ecma` the plugin overlays onto it. Four
cases read back what actually reached the generator.

Nothing exercised watch mode either. Two cases drive a real watcher over a
temporary project: changing the image re-runs the generator and re-emits the
renamed asset, and changing only the module that imports it keeps the rename
while the generator stays at one call -- which is the evidence that
`buildInfo.assetResource` carried it rather than it being reapplied. Both
need a cache, since `production` leaves caching off and then every watch
build rebuilds every module.

The README gains what these pin down: that one `generatorOptions` object is
reused across an array of generators, that `ecma` and `module` are filled in
only when the options leave them unset, and what watch mode does with a
rename.
@alexander-akait
alexander-akait force-pushed the test/generate-option-coverage branch from efea74d to 15e5839 Compare September 5, 2026 11:43
@alexander-akait
alexander-akait merged commit db39bf9 into main Sep 5, 2026
31 checks passed
@alexander-akait
alexander-akait deleted the test/generate-option-coverage branch September 5, 2026 11:49
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