Repository navigation
test(rsbuild-plugin): drive the plugin through its real hook sequence - #957
Merged
Merged
Conversation
The existing suite mocks every file write as already done, which hides ordering. The new suite runs setup against a fake Rsbuild API and fake Rspack compilers with the real compiler and a temporary file system: - the hooks are registered in the order a build runs them, and only the build end when CSS is not extracted - a cold, nested cssDir exists before devup-ui.css is written into it - a same-length edit (red to tan) is served and written - with two environments, only the one whose served sheet went stale asks for one additional pass, and only once per run The cold directory case failed with ENOENT: mkdir and the first write ran side by side in Promise.all. writeDataFiles now awaits mkdir before it writes. Refs #683 (PLG-26) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 🚀 New features to boost your workflow:
|
Conflicts: - rsbuild-plugin/src/plugin.ts: #916 already made writeDataFiles create cssDir before writing devup-ui.css (PLG-10), the same fix as this branch. Kept main's version; the branch no longer changes plugin.ts. - Dropped .changepacks/changepack_log_rsbuild_cold_css_dir.json: the fix it announces shipped in #916, whose changepack covers it, so this branch now only adds hooks.test.ts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
main을 머지하면서 \packages/rsbuild-plugin/src/plugin.ts\ 충돌을 해결했습니다. 이 PR의 PLG-10 수정(\cssDir\를 만든 뒤 \devup-ui.css\를 쓰기)은 #916에 같은 내용으로 이미 들어가 있어서 main 쪽 코드를 그대로 두었습니다. 같은 수정을 알리는 .changepacks/changepack_log_rsbuild_cold_css_dir.json\도 #916의 changepack과 겹쳐서 지웠습니다. 이제 이 PR은 \hooks.test.ts\만 추가합니다. cold directory 테스트를 포함해 \�un test --coverage packages/rsbuild-plugin\는 606 pass이고 \plugin.ts\· |
1 of 2 tasks
4 of 6 tasks
owjs3901
added a commit
that referenced
this pull request
Nov 17, 2026
…rent merges (#990) * test(rsbuild-plugin): expect the MDX post transform in the hook order #957 recorded the hook order before #960 added an order: post transform for .mdx modules. Both landed, so main registers two source transforms and the test failed. Label the MDX transform and expect it last. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(wasm): count removeFile in the documented argument positions #952 counted 45 validated argument positions; #951, merged alongside it, added removeFile.filename, so main validates 46 and the ABI gate failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
owjs3901
added a commit
that referenced
this pull request
Nov 17, 2026
Keep #947's ThemeProvider limitation next to this branch's Bun line, which now also names the packages in include. Rsbuild transforms take both #928's addMissingDependency and this branch's environment, so the merged tests pass both, including #957's hook tests that predate addMissingDependency. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 of 6 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
PLG-26: the existing plugin tests mocked every file write as "already done", so they could not catch problems related to bundler hook call order or the actual file system state. This is the first slice addressing that, starting with the Rsbuild plugin.
Added
packages/rsbuild-plugin/src/__tests__/hooks.test.ts. It uses a fake Rsbuild API and a fake Rspack compiler/compilation, and drives the hooks in the order Rsbuild calls them, on top of the real compiler (WASM) and a temporary-directory file system.onCloseBuild → modifyRspackConfig → onBeforeBuild → transform(cssDir) → modifyRspackConfig → modifyRsbuildConfig → transform(source). WithextractCss: false, onlyonCloseBuildis registered.devup-ui.cssis created even in a nestedcssDirthat does not exist (mkdir deliberately delayed by 20ms).red→tan): checks that the new class's rule is served and also written to the file, and that the file content matches the served content.main.js, setsmodifiedFiles), and the other environment (node) does not. It does not request again in the same run.Bug fix (PLG-10)
The cold directory test failed with
ENOENTon main, becausewriteDataFilesstartedmkdirand the firstwriteFileconcurrently withPromise.all. It now writes aftermkdirfinishes. Since shipped code changed, a@devup-ui/rsbuild-pluginPatch changepack was added.Out of scope here
Test plan
bun test packages/rsbuild-plugin/src/__tests__/hooks.test.ts(5 pass); confirmed the cold directory test fails with ENOENT against main'splugin.tsbun test --coverage packages/rsbuild-plugin(603 pass,plugin.ts·reservation.ts100%)tsc(included in the package build)publishjob passes요약
PLG-26: 기존 플러그인 테스트가 파일 쓰기를 모두 "이미 끝난 것"으로 mock해서, bundler hook의 호출 순서나 실제 파일 시스템 상태와 관련된 문제를 잡지 못하던 부분에 대한 첫 번째 slice입니다. 먼저 Rsbuild 플러그인부터 다룹니다.
packages/rsbuild-plugin/src/__tests__/hooks.test.ts를 추가했습니다. fake Rsbuild API와 fake Rspack compiler/compilation을 쓰고, 실제 compiler(WASM)와 임시 디렉터리 파일 시스템 위에서 Rsbuild가 부르는 순서대로 hook을 구동합니다.onCloseBuild → modifyRspackConfig → onBeforeBuild → transform(cssDir) → modifyRspackConfig → modifyRsbuildConfig → transform(source).extractCss: false일 때는onCloseBuild만 등록됩니다.cssDir(mkdir을 일부러 20ms 늦춤)에서도devup-ui.css가 만들어지는지 확인합니다.red→tan): 새 class의 규칙이 서빙되고 파일에도 쓰이는지, 파일 내용과 서빙 내용이 같은지 확인합니다.main.js삭제,modifiedFiles설정), 다른 environment(node)는 요청하지 않습니다. 같은 run에서는 다시 요청하지 않습니다.버그 수정 (PLG-10)
cold directory 테스트가 main에서
ENOENT로 실패했습니다.writeDataFiles가mkdir과 첫writeFile을Promise.all로 동시에 시작했기 때문입니다. 이제mkdir이 끝난 뒤에 씁니다. 배포 코드가 바뀌어서@devup-ui/rsbuild-pluginPatch changepack을 추가했습니다.이번 범위에서 제외
테스트 계획
bun test packages/rsbuild-plugin/src/__tests__/hooks.test.ts(5 pass), main의plugin.ts에서는 cold directory 테스트가 ENOENT로 실패하는 것 확인bun test --coverage packages/rsbuild-plugin(603 pass,plugin.ts·reservation.ts100%)tsc(패키지 build에 포함)publishjob 통과Refs #683
🤖 Generated with Claude Code