Skip to content

test: custom resource loader of test cases#12091

Merged
LingyuCoder merged 1 commit intomainfrom
test/resource-loader
Nov 5, 2025
Merged

test: custom resource loader of test cases#12091
LingyuCoder merged 1 commit intomainfrom
test/resource-loader

Conversation

@LingyuCoder
Copy link
Copy Markdown
Contributor

Summary

The jsdom runner is quite different with FakeDocument. If the script.onerror/onload function is called, the script will continue fetching the resource by resource loader. Some cases need to stop this behavior. So add a resourceLoader option to test.config.js which can define it. If the resourceLoader returned undefined, the default resource loader will be used.

Related links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@LingyuCoder LingyuCoder requested review from 9aoy and Copilot November 5, 2025 08:02
@github-actions github-actions bot added the team The issue/pr is created by the member of Rspack. label Nov 5, 2025
@netlify
Copy link
Copy Markdown

netlify bot commented Nov 5, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit 2889c17
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/690b04b2cec95a00096e5777

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 resourceLoader option 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.js files
  • 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 resourceLoader function signature includes element parameter but the type definition shows it should accept two separate parameters (url: string, element: HTMLScriptElement). However, the implementation calls it correctly. Consider documenting what returning null vs undefined means, 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.

@LingyuCoder LingyuCoder enabled auto-merge (squash) November 5, 2025 08:06
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Nov 5, 2025

📦 Binary Size-limit

Comparing 2889c17 to fix: new URL("", import.meta.url) should be pure (#12076) by harpsealjs

🙈 Size remains the same at 47.85MB

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Nov 5, 2025

CodSpeed Performance Report

Merging #12091 will not alter performance

Comparing test/resource-loader (2889c17) with main (498466d)

Summary

✅ 17 untouched

@LingyuCoder LingyuCoder merged commit e2f02f1 into main Nov 5, 2025
53 checks passed
@LingyuCoder LingyuCoder deleted the test/resource-loader branch November 5, 2025 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants