Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: easier way to write hmr test cases #8849

Merged
merged 4 commits into from
Dec 30, 2024
Merged

Conversation

LingyuCoder
Copy link
Contributor

@LingyuCoder LingyuCoder commented Dec 25, 2024

Summary

before:

expect(value).toBe(1);
NEXT(require("../../update")(done, true, () => {
	expect(value).toBe(2);
	NEXT(require("../../update")(done, true, () => {
		expect(value).toBe(1);
		NEXT(require("../../update")(done, true, () => {
			expect(value).toBe(3);
			done();
		}))
	}));
}));

after:

expect(value).toBe(1);
await NEXT_HMR();
expect(value).toBe(2);
await NEXT_HMR();
expect(value).toBe(1);
await NEXT_HMR();
expect(value).toBe(3);

generated by copilot

This pull request includes several important changes to the rspack-test-tools package, focusing on improving hot module replacement (HMR) support, simplifying the codebase, and updating test snapshots.

Improvements to HMR support:

  • Added new HMR support methods in packages/rspack-test-tools/src/helper/legacy/fake-update-loader.js to handle module reexports and runtime updates.
  • Introduced TestHotUpdatePlugin to enhance HMR functionality in HotProcessor and updated the loader path for hot updates. [1] [2] [3]

Codebase simplification:

  • Refactored checkArrayExpectation calls to use async/await, removing unnecessary promise wrappers in multiple files (basic.ts, watch.ts, cache.ts). [1] [2] [3] [4]
  • Updated HotStepRunnerFactory and HotRunnerFactory to use async/await for the next function and introduced nextHMR for handling HMR updates. [1] [2] [3] [4] [5]

Test snapshot updates:

  • Updated test snapshots to reflect changes in HMR behavior and file updates across various test cases (ensure-chunk-change-to-promise-all, recovery-cacheable, recovery, hash/hot-index, recover-after-self-error, dispose-removed-module, replace-runtime-module, require-disposed-module-warning, self-accept-factory). [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]

Checklist

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

@github-actions github-actions bot added the team The issue/pr is created by the member of Rspack. label Dec 25, 2024
Copy link

netlify bot commented Dec 25, 2024

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit 4301102
🔍 Latest deploy log https://app.netlify.com/sites/rspack/deploys/6772375eac8cc20008c4cde3

Copy link

codspeed-hq bot commented Dec 25, 2024

CodSpeed Performance Report

Merging #8849 will not alter performance

Comparing test/easier-hmr-case (4301102) with main (437c370)

Summary

✅ 3 untouched benchmarks

@LingyuCoder LingyuCoder marked this pull request as ready for review December 30, 2024 05:56
@LingyuCoder LingyuCoder merged commit 69184c4 into main Dec 30, 2024
32 checks passed
@LingyuCoder LingyuCoder deleted the test/easier-hmr-case branch December 30, 2024 06:41
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.

2 participants