test: custom resource loader of test cases#12091
Merged
LingyuCoder merged 1 commit intomainfrom Nov 5, 2025
Merged
Conversation
✅ Deploy Preview for rspack canceled.
|
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR enables previously disabled test cases by implementing a custom resource loader feature for web tests. The changes allow tests to intercept and control resource loading behavior in JSDOM-based web tests, while also improving error reporting.
- Introduces a
resourceLoaderoption in test configuration to customize script loading behavior - Enhances error handling with better stack traces and source code context for JSDOM test failures
- Re-enables 5 previously skipped test cases by removing their
test.filter.jsfiles - Updates error expectations for WebAssembly experiment test to match current behavior
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/rspack-test/configCases/web/retry-failed-import/test.filter.js | Removed filter to enable retry import test |
| tests/rspack-test/configCases/web/retry-failed-import/test.config.js | Adds resource loader to simulate failed script loads |
| tests/rspack-test/configCases/web/node-source-future-defaults/warnings.js | Removed warnings file (test no longer expects warnings) |
| tests/rspack-test/configCases/web/node-source-future-defaults/test.filter.js | Removed filter to enable node source test |
| tests/rspack-test/configCases/web/attach-existing/test.filter.js | Removed filter to enable attach existing script test |
| tests/rspack-test/configCases/web/attach-existing/test.config.js | Adds resource loader to handle custom script URLs |
| tests/rspack-test/configCases/wasm/missing-wasm-experiment/test.filter.js | Removed filter to enable wasm experiment test |
| tests/rspack-test/configCases/wasm/missing-wasm-experiment/errors.js | Updated error expectation to match actual behavior |
| tests/rspack-test/configCases/url/dynamic-template-literals-expr/test.filter.js | Changed FIXME to TODO comment |
| tests/rspack-test/configCases/split-chunks/issue-9491/test.filter.js | Removed filter to enable split-chunks test |
| packages/rspack-test-tools/src/type.ts | Added resourceLoader option to TTestConfig type definition |
| packages/rspack-test-tools/src/runner/web/index.ts | Implemented custom resource loading and enhanced error reporting |
| packages/rspack-test-tools/etc/test-tools.api.md | Updated API documentation for new features |
Comments suppressed due to low confidence (1)
packages/rspack-test-tools/src/runner/web/index.ts:1
- The
resourceLoaderfunction signature includeselementparameter but the type definition shows it should accept two separate parameters(url: string, element: HTMLScriptElement). However, the implementation calls it correctly. Consider documenting what returningnullvsundefinedmeans, as the implementation treats them differently at line 113.
import fs from "node:fs";
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9aoy
approved these changes
Nov 5, 2025
Contributor
📦 Binary Size-limit
🙈 Size remains the same at 47.85MB |
CodSpeed Performance ReportMerging #12091 will not alter performanceComparing Summary
|
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
The jsdom runner is quite different with FakeDocument. If the
script.onerror/onloadfunction is called, the script will continue fetching the resource by resource loader. Some cases need to stop this behavior. So add aresourceLoaderoption totest.config.jswhich can define it. If theresourceLoaderreturnedundefined, the default resource loader will be used.Related links
Checklist