test: cover generatorOptions and the rename under watch - #721
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
`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.
efea74d to
15e5839
Compare
Summary
generatorOptionshad no test at all — zero occurrences undertest/— so nothing held the array-positional and shared-object contracts it borrows fromminimizerOptions, nor theecmathe plugin overlays onto it. Nothing exercised watch mode either:.watch(did not appear anywhere intest/.Worth knowing when reading the diff: the three existing
generate optioncases self-skip on the webpack this repo locks, becauseNormalModule.processResultis aSyncWaterfallHookin every published webpack. Making their guard throw shows all three returning early. They were verified against webpackmain, 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
generatorOptionscases intest/generate-option.test.js, andtest/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 thatbuildInfo.assetResourcecarried it rather than it being reapplied. Both need a cache, sinceproductionleaves 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
generatorOptionsobject is reused across an array of generators, thatecmaandmoduleare 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/forgeneratorOptionsand 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 missingcachecame to light.🤖 Generated with Claude Code
https://claude.ai/code/session_016TQeNpahUSDUjD2Crugy5H
Generated by Claude Code