Skip to content

test: add coverage for generateStatsFile and statsFilename - #735

Open
topdaily-dev wants to merge 1 commit into
webpack:mainfrom
topdaily-dev:test/cover-generate-stats-file
Open

topdaily-dev wants to merge 1 commit into
webpack:mainfrom
topdaily-dev:test/cover-generate-stats-file

Conversation

@topdaily-dev

@topdaily-dev topdaily-dev commented Aug 24, 2026 •

Copy link
Copy Markdown

Summary

Adds plugin-level test coverage for the generateStatsFile and statsFilename options.

Both are documented public options, but neither had coverage at the plugin level. test/statsUtils.js only exercises the low-level writeStats helper, so the option wiring in BundleAnalyzerPlugin was never verified by CI — including the mkdir call that creates missing directories for a nested statsFilename.

The tests use analyzerMode: "disabled" together with generateStatsFile: true, which is the combination the README describes for generating only the stats file.

Covered:

  • generateStatsFile: true writes the stats file (webpack 4 and 5)
  • no stats file is written by default
  • a custom relative statsFilename
  • a nested statsFilename, exercising the recursive directory creation
  • an absolute statsFilename

What kind of change does this PR introduce?

test. No production code is modified; the only changed file is test/plugin.js.

Did you add tests for your changes?

The change is entirely tests. I confirmed they are meaningful rather than vacuous by temporarily short-circuiting the generateStatsFile branch in BundleAnalyzerPlugin: the five positive tests fail and the negative test still passes. I reverted that local experiment before pushing.

npm run lint and the full suite pass locally. The suite requires npm run build first, since the viewer bundle must exist for getAssetContent.

Does this PR introduce a breaking change?

No. No runtime behaviour changes, so no changeset is included — merging this will not require a version bump.

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

Nothing. The options are already documented in the README; this only adds coverage for the documented behaviour.

Use of AI

Yes, disclosed per the AI policy. I used an AI coding assistant to help explore the test suite, identify which documented options lacked plugin-level coverage, and draft the test cases. I reviewed the full diff myself before requesting review, and designed and ran the verification described above — short-circuiting the generateStatsFile branch to confirm the tests fail without the feature — specifically to satisfy myself that the coverage is real and not just passing by construction. I understand the change and can answer questions about it.

@changeset-bot

changeset-bot Bot commented Aug 24, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: f199df2

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

@linux-foundation-easycla

linux-foundation-easycla Bot commented Aug 24, 2026 •

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: topdaily-dev / name: TopDaily Dev (f199df2)

@topdaily-dev
topdaily-dev force-pushed the test/cover-generate-stats-file branch from 6f3c22c to f199df2 Compare August 24, 2026 17:46
@valscion

Copy link
Copy Markdown
Collaborator

Please fill the pull request template as it was.

@codecov

codecov Bot commented Aug 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.52%. Comparing base (a4d4123) to head (f199df2).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #735      +/-   ##
==========================================
+ Coverage   78.58%   79.52%   +0.94%     
==========================================
  Files          17       17              
  Lines        1060     1060              
  Branches      383      383              
==========================================
+ Hits          833      843      +10     
+ Misses        199      189      -10     
  Partials       28       28              

☔ 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.

@topdaily-dev

Copy link
Copy Markdown
Author

@valscion I've restored and filled in the pull request template, including the Use of AI section. The template is set at the org level in webpack/.github rather than in this repo, which is why it wasn't present in my original description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants