You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test: make the suite runnable cold and fail on webpack/rspack build errors - #629
Implements plans/001-test-harness.md: makes the test suite trustworthy and runnable from a clean clone. No runtime (src/) changes.
pnpm test builds first. The webpack/rspack adapters load their loaders from dist/ under vitest (import.meta.dev), so a fresh clone failed with confusing loader errors. test is now nr build && nr test:build && vitest run; a new test:unit script runs only test/unit-tests for the fast loop after a build.
Fixture builder fixed.rm(dist) was missing { recursive: true }, rejected with ERR_FS_EISDIR and was swallowed, so stale output was never cleaned. The 21 --version spawns are gone, the seven bundlers of a fixture now build concurrently (each writes to its own dist/<bundler>), a failing bundler no longer aborts the rest, and a second positional arg filters by bundler: pnpm test:build transform webpack.
webpack/rspack integration tests reject on build errors. 16 call sites used build.webpack(config, resolve) and passed whatever the compilation reported. They now go through runWebpack/runRspack in test/unit-tests/utils.ts, which reject on stats.hasErrors().
Loader filter tests use real filter shapes.filter: vi.fn().mockReturnValue(false) is not a filter — normalizeObjectHook reads filter.id/filter.code, finds undefined, and matches everything. The "filter does not match" tests passed only because the handler mock returned undefined. They now use { id: /\.never-matches$/ } and assert the handler is not called (so the binary pass-through test from fix(webpack): keep binary files intact in the load and transform loaders #623 actually tests the pass-through).
Making the webpack/rspack runners honest surfaced that test/unit-tests/id-consistency had been producing erroring builds all along: externals: ['node:path'] with the default externalsType: 'var' emits var x = node:path, which neither webpack nor rspack can parse. The hook-count assertions still passed, so nobody noticed. Fixed by setting externalsType: 'commonjs' in that test.
The pull request updates fixture builds to run asynchronously and concurrently. It adds shared Webpack and Rspack test runners, updates compiler tests to use them, changes loader filter fixtures to regular expressions, and adjusts test scripts and repository metadata.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements
plans/001-test-harness.md: makes the test suite trustworthy and runnable from a clean clone. No runtime (src/) changes.pnpm testbuilds first. The webpack/rspack adapters load their loaders fromdist/under vitest (import.meta.dev), so a fresh clone failed with confusing loader errors.testis nownr build && nr test:build && vitest run; a newtest:unitscript runs onlytest/unit-testsfor the fast loop after a build.rm(dist)was missing{ recursive: true }, rejected withERR_FS_EISDIRand was swallowed, so stale output was never cleaned. The 21--versionspawns are gone, the seven bundlers of a fixture now build concurrently (each writes to its owndist/<bundler>), a failing bundler no longer aborts the rest, and a second positional arg filters by bundler:pnpm test:build transform webpack.build.webpack(config, resolve)and passed whatever the compilation reported. They now go throughrunWebpack/runRspackintest/unit-tests/utils.ts, which reject onstats.hasErrors().filter: vi.fn().mockReturnValue(false)is not a filter —normalizeObjectHookreadsfilter.id/filter.code, findsundefined, and matches everything. The "filter does not match" tests passed only because the handler mock returnedundefined. They now use{ id: /\.never-matches$/ }and assert the handler is not called (so the binary pass-through test from fix(webpack): keep binary files intact in the load and transform loaders #623 actually tests the pass-through).plans/**is excluded from ESLint: the plan documents' illustrative code blocks madepnpm lintfail onmainafter docs: add advisor implementation plans from codebase audit #628.Found along the way
Making the webpack/rspack runners honest surfaced that
test/unit-tests/id-consistencyhad been producing erroring builds all along:externals: ['node:path']with the defaultexternalsType: 'var'emitsvar x = node:path, which neither webpack nor rspack can parse. The hook-count assertions still passed, so nobody noticed. Fixed by settingexternalsType: 'commonjs'in that test.Verification
rm -rf dist test/fixtures/*/dist && pnpm test→ 200 passed, 63 skippedpnpm test:unit,pnpm lint,pnpm typecheck→ greenCreated with the help of an agent.
Summary by CodeRabbit
Tests
Chores