Skip to content

test: cover devMiddleware.writeToDisk with output.clean - #5802

Merged
alexander-akait merged 4 commits into
mainfrom
test/write-to-disk-clean
Nov 16, 2026
Merged

alexander-akait merged 4 commits into
mainfrom
test/write-to-disk-clean

Conversation

@alexander-akait

@alexander-akait alexander-akait commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

This adds tests through webpack-dev-server for webpack/webpack-dev-middleware#861, fixed in webpack/webpack-dev-middleware#2497. The project uses:

  • output.clean: true;
  • output.copy from public/;
  • a stale dist/stale.js.

Each case runs in both modes: as a server of its own (new Server(options, compiler)) and as a plugin (server.apply(compiler)).

  • With devMiddleware.writeToDisk: (p) => !p.endsWith(".svg"), on a middleware that cleans the disk:
    • the first build leaves [main.<hash>.js, robots.txt], so the stale file is cleaned;
    • logo.svg is served from memory and kept off disk;
    • a rebuild with a new hash leaves one bundle;
    • removing public/robots.txt cleans it from disk.
  • With writeToDisk: true and a file system of your own in memory, given in devMiddleware.outputFileSystem or set on the compiler:
    • the files are written to disk and to it, and served from it;
    • after a rebuild, both hold the one new bundle.
  • On an earlier middleware: the files are written, and nothing is cleaned.

The tests check which case applies from the middleware alone: whether it gives the compiler a file system of its own. A next-major TODO is left to drop that check. Locally, everything passes in both modes:

This changes only tests: test/e2e/write-to-disk-clean.test.js and a test/ports-map.js entry. There is no code change and no changeset.

🤖 Generated with Claude Code

https://claude.ai/code/session_01UjuMAuk9o6UazjHzcAQCTA

Summary by CodeRabbit

  • Tests
    • Added end-to-end coverage for disk writes and cleanup of stale, replaced, and no-longer-copied files across rebuilds.
    • Tested standalone server and plugin configurations, including setups that use an additional in-memory filesystem.
    • Verified that copied SVG files can still be served when excluded from disk writes.
    • Added compatibility coverage for middleware without separate output filesystems and registered the tests in the port map.

Cover both the server of its own and the plugin mode: the stale file and
the previous bundle are cleaned from disk, a file no longer copied is
removed, and what `writeToDisk` leaves out is served from memory only.
Where webpack-dev-middleware does not clean the disk yet, check that the
files are written without cleaning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UjuMAuk9o6UazjHzcAQCTA
@changeset-bot

changeset-bot Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 8022b30

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

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Adds end-to-end tests for devMiddleware.writeToDisk with webpack’s output.clean in standalone-server and plugin modes. The tests cover stale-file cleanup, excluded SVG handling, bundle replacement, and deleted copied-file cleanup across rebuilds. They also check separate memory filesystem configurations and the older middleware behavior.

Merge Risk: Minimal · up to 8022b

This change only adds end-to-end tests for write-to-disk cleaning and a test port mapping. It has no production impact, and no merge-blocking risk is identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "test: cover devMiddleware.writeToDisk with output.clean" matches the main change. The PR adds end-to-end tests for devMiddleware.writeToDisk combined with output.clean, plus a ports-map ent…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "test: cover devMiddleware.writeToDisk with output.clean" matches the main change. The PR adds end-to-end tests for devMiddleware.writeToDisk combined with output.clean, plus a ports-map entry for the new test. The title is specific, short, and uses the conventional test: prefix. It does not cover every detail, such as the in-memory filesystem case or the capability-based skip logic, which is acceptable.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 57359a75-072b-4e19-b1d0-b0d7e2317b69
Commits

Reviewing files that changed from the base of the PR and between 89dd1bb and 8022b30.

Files selected for processing: 1

  • test/e2e/write-to-disk-clean.test.js

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 944d2da6-ec2b-4cc0-af17-f899d035a1f2
Commits

Reviewing files that changed from the base of the PR and between bb2680f and 78dae08.

Files selected for processing: 2

  • test/e2e/write-to-disk-clean.test.js
  • test/ports-map.js

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Comment thread test/e2e/write-to-disk-clean.test.js Resolved
alexander-akait and others added 3 commits November 13, 2026 16:47
A build restarted for a change keeps the startTime it began with, so it
could be taken for the build before the change and never awaited.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UjuMAuk9o6UazjHzcAQCTA
In both modes, with `writeToDisk: true` and a file system in memory given
in `devMiddleware.outputFileSystem` or set on the compiler, the files are
written to disk and to it, served from it, and both are cleaned.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UjuMAuk9o6UazjHzcAQCTA
memfs lists recursively with the full path on Windows, so the files were
looked up under the output directory twice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UjuMAuk9o6UazjHzcAQCTA

alexander-akait commented Nov 13, 2026 •

Copy link
Copy Markdown
Member Author

Test - macos-latest - Node v26.x failed on 8022b30 in test/e2e/logging.test.js ("should work and do not log messages about hot and live reloading is enabled (ws)"): Puppeteer's Network.enable timed out while opening the page, after 181 s. That file isn't in this PR's diff. The new ports-map entry is appended last, so no other test's port moves, and write-to-disk-clean.test.js passed in the same job. The Ubuntu, Windows, macOS Node v22 and lint jobs passed. macOS Node v24 hadn't finished, and I've re-run the failed jobs once to confirm.


Generated by Claude Code

@codecov

codecov Bot commented Nov 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.91%. Comparing base (bb2680f) to head (8022b30).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5802   +/-   ##
=======================================
  Coverage   95.91%   95.91%           
=======================================
  Files           6        6           
  Lines        5707     5707           
=======================================
  Hits         5474     5474           
  Misses        233      233           

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

@alexander-akait
alexander-akait merged commit 796262e into main Nov 16, 2026
26 of 28 checks passed
@alexander-akait
alexander-akait deleted the test/write-to-disk-clean branch November 16, 2026 01:16
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