test: streamline custom message tests#7027
Conversation
Summary of ChangesHello @chenjiahan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on improving the efficiency and clarity of end-to-end tests related to custom server messages. By modifying a core test helper to expose the development server instance, it enables a more streamlined approach to writing and maintaining tests that interact with the server, ultimately making the test suite more robust and easier to understand. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Deploying rsbuild with
|
| Latest commit: |
b535cd4
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://91042d09.rsbuild-v2.pages.dev |
| Branch Preview URL: | https://custom-msg-test-0124.rsbuild-v2.pages.dev |
There was a problem hiding this comment.
Code Review
This pull request effectively streamlines the custom message tests by enhancing the dev test helper to return the dev server instance. This change significantly reduces boilerplate code in the test files, making them cleaner and easier to maintain. The use of copySrcDir and editFile helpers is also a great improvement over manual file system operations. My only suggestion is to consider adding an explicit assertion for the server instance in the tests to improve debuggability in case the dev helper fails to provide it.
There was a problem hiding this comment.
Pull request overview
This PR refactors the custom message tests to use the enhanced dev helper function, which now returns the running dev server instance. This change eliminates repetitive setup and teardown boilerplate code.
Changes:
- Modified
devhelper to capture and return the dev server instance viaonBeforeStartDevServerhook - Refactored custom message tests to use the new
devhelper with built-in cleanup - Removed manual server creation, listener setup, and cleanup code from tests
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| e2e/helper/jsApi.ts | Added RsbuildDevServer import, captured server via onBeforeStartDevServer hook, and included it in the return object |
| e2e/cases/javascript-api/server-custom-message/index.test.ts | Refactored tests to use dev fixture instead of manual server creation and cleanup, utilizing new test helpers like copySrcDir and editFile |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
devtest helper now returns the running dev server instancedevhelper, resulting in less repetitive setup and teardown codeRelated
Checklist