Skip to content

test: migrate tests to rstest#75

Merged
chenjiahan merged 12 commits intomainfrom
rstest
Feb 14, 2026
Merged

test: migrate tests to rstest#75
chenjiahan merged 12 commits intomainfrom
rstest

Conversation

@9aoy
Copy link
Collaborator

@9aoy 9aoy commented Feb 14, 2026

migrate tests to rstest.

Copilot AI review requested due to automatic review settings February 14, 2026 06:49
@gemini-code-assist
Copy link

Summary of Changes

Hello @9aoy, 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 undertakes a significant refactoring of the project's testing infrastructure by migrating from the Jest framework to rstest. The change aims to streamline the testing process and potentially leverage new features or performance benefits offered by rstest. It involves updating core configurations, modifying test files to use the new API, and adjusting project dependencies accordingly.

Highlights

  • Testing Framework Migration: The project's test suite has been migrated from Jest to rstest, a new testing framework. This involves updating test configurations, scripts, and individual test files to align with the rstest API.
  • Dependency Updates: Jest-related dependencies and configuration files (jest.config.js, scripts/patch-node-env.cjs, tests/helpers/sequencer.js, tests/helpers/snapshot-resolver.js) have been removed. The @rstest/core package has been added, and package.json scripts were updated to use rstest.
  • Test File Adaptations: Existing test files have been modified to replace Jest-specific functions (e.g., jest.fn, jest.spyOn, jest.mock, jest.setTimeout) with their rstest equivalents (rstest.fn, rstest.spyOn, rs.doMockRequire, rstest.setConfig). Snapshot files were also updated to reflect the new rstest format.
  • Rstest Configuration: A new configuration file, rstest.config.ts, has been introduced to define rstest's global settings, test inclusion/exclusion patterns, worker pool configuration, environment variables, test timeouts, and snapshot resolution logic.
  • Compatibility Patches: Temporary patches for process.binding('http_parser') and Module._resolveFilename were added in tests/helpers/setup-test.js to ensure compatibility with rstest, addressing potential issues with eventsource and require.resolve.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • jest.config.js
    • Removed Jest configuration file.
  • package.json
    • Updated the 'test' script to use 'rstest'.
    • Removed Jest-related development dependencies.
    • Added '@rstest/core' as a development dependency.
    • Adjusted other development dependencies.
  • rstest.config.ts
    • Added new rstest configuration file defining test patterns, timeouts, and snapshot resolution.
  • scripts/patch-node-env.cjs
    • Removed custom Node.js environment patching script.
  • tests/e2e/snapshots/allowed-hosts.test.js.snap.webpack5
    • Updated snapshot header to 'Rstest Snapshot v1'.
    • Adjusted test names to reflect rstest's hierarchical naming convention.
  • tests/e2e/snapshots/api.test.js.snap.webpack5
    • Updated snapshot header to 'Rstest Snapshot v1'.
    • Adjusted test names to reflect rstest's hierarchical naming convention.
    • Updated error message format for port not found.
  • tests/e2e/snapshots/app.test.js.snap.webpack5
    • Updated snapshot header to 'Rstest Snapshot v1'.
    • Adjusted test names to reflect rstest's hierarchical naming convention.
  • tests/e2e/snapshots/bonjour.test.js.snap.webpack5
    • Updated snapshot header to 'Rstest Snapshot v1'.
    • Adjusted test names to reflect rstest's hierarchical naming convention.
  • tests/e2e/snapshots/built-in-routes.test.js.snap.webpack5
    • Updated snapshot header to 'Rstest Snapshot v1'.
    • Adjusted test names to reflect rstest's hierarchical naming convention.
  • tests/e2e/snapshots/client-reconnect.test.js.snap.webpack5
    • Updated snapshot header to 'Rstest Snapshot v1'.
    • Adjusted test names to reflect rstest's hierarchical naming convention.
  • tests/e2e/snapshots/client.test.js.snap.webpack5
    • Updated snapshot header to 'Rstest Snapshot v1'.
    • Adjusted test names to reflect rstest's hierarchical naming convention.
  • tests/e2e/snapshots/compress.test.js.snap.webpack5
    • Updated snapshot header to 'Rstest Snapshot v1'.
    • Adjusted test names to reflect rstest's hierarchical naming convention.
  • tests/e2e/snapshots/entry.test.js.snap.webpack5
    • Updated snapshot header to 'Rstest Snapshot v1'.
    • Adjusted test names to reflect rstest's hierarchical naming convention.
  • tests/e2e/snapshots/headers.test.js.snap.webpack5
    • Updated snapshot header to 'Rstest Snapshot v1'.
    • Adjusted test names to reflect rstest's hierarchical naming convention.
  • tests/e2e/snapshots/history-api-fallback.test.js.snap.webpack5
    • Updated snapshot header to 'Rstest Snapshot v1'.
    • Adjusted test names to reflect rstest's hierarchical naming convention.
  • tests/e2e/snapshots/hot-and-live-reload.test.js.snap.webpack5
    • Updated snapshot header to 'Rstest Snapshot v1'.
    • Adjusted test names to reflect rstest's hierarchical naming convention.
  • tests/e2e/snapshots/ipc.test.js.snap.webpack5
    • Updated snapshot header to 'Rstest Snapshot v1'.
    • Adjusted test names to reflect rstest's hierarchical naming convention.
  • tests/e2e/snapshots/logging.test.js.snap.webpack5
    • Updated snapshot header to 'Rstest Snapshot v1'.
    • Adjusted test names to reflect rstest's hierarchical naming convention.
  • tests/e2e/snapshots/mime-types.test.js.snap.webpack5
    • Updated snapshot header to 'Rstest Snapshot v1'.
    • Adjusted test names to reflect rstest's hierarchical naming convention.
  • tests/e2e/snapshots/module-federation.test.js.snap.webpack5
    • Updated snapshot header to 'Rstest Snapshot v1'.
    • Adjusted test names to reflect rstest's hierarchical naming convention.
  • tests/e2e/snapshots/multi-compiler.test.js.snap.webpack5
    • Updated snapshot header to 'Rstest Snapshot v1'.
    • Adjusted test names to reflect rstest's hierarchical naming convention.
  • tests/e2e/snapshots/on-listening.test.js.snap.webpack5
    • Updated snapshot header to 'Rstest Snapshot v1'.
    • Adjusted test names to reflect rstest's hierarchical naming convention.
  • tests/e2e/snapshots/overlay.test.js.snap.webpack5
    • Updated snapshot header to 'Rstest Snapshot v1'.
    • Adjusted test names to reflect rstest's hierarchical naming convention.
    • Updated error messages in snapshots.
  • tests/e2e/snapshots/port.test.js.snap.webpack5
    • Updated snapshot header to 'Rstest Snapshot v1'.
    • Adjusted test names to reflect rstest's hierarchical naming convention.
  • tests/e2e/snapshots/server-and-client-transport.test.js.snap.webpack5
    • Updated snapshot header to 'Rstest Snapshot v1'.
    • Adjusted test names to reflect rstest's hierarchical naming convention.
    • Updated error message format for transport errors.
  • tests/e2e/snapshots/server.test.js.snap.webpack5
    • Updated snapshot header to 'Rstest Snapshot v1'.
    • Adjusted test names to reflect rstest's hierarchical naming convention.
  • tests/e2e/snapshots/setup-exit-signals.test.js.snap.webpack5
    • Updated snapshot header to 'Rstest Snapshot v1'.
    • Adjusted test names to reflect rstest's hierarchical naming convention.
  • tests/e2e/snapshots/setup-middlewares.test.js.snap.webpack5
    • Updated snapshot header to 'Rstest Snapshot v1'.
    • Adjusted test names to reflect rstest's hierarchical naming convention.
  • tests/e2e/snapshots/static-directory.test.js.snap.webpack5
    • Updated snapshot header to 'Rstest Snapshot v1'.
    • Adjusted test names to reflect rstest's hierarchical naming convention.
  • tests/e2e/snapshots/static-public-path.test.js.snap.webpack5
    • Updated snapshot header to 'Rstest Snapshot v1'.
    • Adjusted test names to reflect rstest's hierarchical naming convention.
  • tests/e2e/snapshots/stats.test.js.snap.webpack5
    • Updated snapshot header to 'Rstest Snapshot v1'.
    • Adjusted test names to reflect rstest's hierarchical naming convention.
  • tests/e2e/snapshots/target.test.js.snap.webpack5
    • Updated snapshot header to 'Rstest Snapshot v1'.
    • Adjusted test names to reflect rstest's hierarchical naming convention.
  • tests/e2e/snapshots/web-socket-communication.test.js.snap.webpack5
    • Updated snapshot header to 'Rstest Snapshot v1'.
    • Adjusted test names to reflect rstest's hierarchical naming convention.
  • tests/e2e/snapshots/web-socket-server.test.js.snap.webpack5
    • Updated snapshot header to 'Rstest Snapshot v1'.
    • Adjusted test names to reflect rstest's hierarchical naming convention.
  • tests/e2e/api.test.js
    • Replaced jest.resetModules() with rstest.resetModules().
    • Replaced jest.fn() with rstest.fn().
    • Replaced jest.mock with rs.doMockRequire.
    • Updated expect().rejects.toThrowErrorMatchingSnapshot() for rstest compatibility.
  • tests/e2e/bonjour.test.js
    • Replaced jest.fn() with rstest.fn().
    • Replaced jest.mock with rs.doMockRequire.
  • tests/e2e/history-api-fallback.test.js
    • Replaced jest.spyOn() with rstest.spyOn().
  • tests/e2e/hot-and-live-reload.test.js
    • Updated commented-out lines to use rstest.fn() and rstest.spyOn().
  • tests/e2e/lazy-compilation.test.js
    • Updated comment regarding eventsource fix for test freezing.
  • tests/e2e/overlay.test.js
    • Added local variables for pathToFile and originalCode.
    • Replaced jest.mock with rs.doMockRequire.
    • Replaced jest.fn() with rstest.fn().
    • Added fs.writeFileSync and rs.doUnmock in the finally block.
  • tests/e2e/server.test.js
    • Replaced jest.spyOn() with rstest.spyOn().
  • tests/e2e/setup-exit-signals.test.js
    • Replaced jest.spyOn() with rstest.spyOn().
  • tests/e2e/static-directory.test.js
    • Converted watcher tests to use async/await with Promise for event handling.
    • Replaced jest.spyOn() with rstest.spyOn().
  • tests/e2e/static-public-path.test.js
    • Replaced jest.spyOn() with rstest.spyOn().
  • tests/e2e/stats.test.js
    • Replaced global.console.log = jest.fn() with global.console.log = rstest.fn().
  • tests/e2e/watch-files.test.js
    • Replaced jest.spyOn() with rstest.spyOn().
  • tests/e2e/web-socket-communication.test.js
    • Replaced jest.setTimeout() with rstest.setConfig({ testTimeout: ... }).
  • tests/fixtures/worker-config-dev-server-false/public/worker-bundle.js
    • Adjusted file formatting by adding a newline at the end.
  • tests/helpers/global-setup-test.js
    • Removed port validation logic.
  • tests/helpers/normalize.js
    • Removed Jest-related normalization for TAPABLE module.
  • tests/helpers/sequencer.js
    • Removed Jest test sequencer file.
  • tests/helpers/setup-test.js
    • Removed jest.setTimeout().
    • Added process.binding('http_parser') patch for Node.js compatibility.
    • Added Module._resolveFilename patch for rstest require.resolve issues.
  • tests/helpers/snapshot-resolver.js
    • Removed Jest snapshot resolver file.
  • tests/helpers/test-server.js
    • Updated comment from 'jest' to 'the test runner' for broader applicability.
  • tests/normalizeOptions.test.ts
    • Removed jest-serializer-path import and expect.addSnapshotSerializer call.
  • tests/rstest-env.d.ts
    • Added new TypeScript declaration file for rstest globals.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

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 pull request migrates the test suite from Jest to rstest, a testing framework. The migration involves updating test runner configuration, replacing Jest-specific APIs with rstest equivalents, modernizing async test patterns, and updating snapshot file headers.

Changes:

  • Replaced Jest with rstest test runner and updated all test APIs (jest.fn → rstest.fn, jest.spyOn → rstest.spyOn, etc.)
  • Created new rstest.config.ts configuration and removed Jest-specific configuration files
  • Updated test helpers including setup-test.js with rstest-specific workarounds and removed Jest-only files like snapshot-resolver.js and sequencer.js

Reviewed changes

Copilot reviewed 53 out of 56 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
rstest.config.ts New rstest configuration with snapshot resolution and test setup
package.json Updated dependencies: removed Jest packages, added @rstest/core
jest.config.js Removed Jest configuration
tests/helpers/setup-test.js Added rstest-specific module resolution workarounds and process.binding polyfill
tests/helpers/snapshot-resolver.js Removed (functionality moved to rstest.config.ts)
tests/helpers/sequencer.js Removed Jest test sequencer
tests/helpers/global-setup-test.js Removed port validation logic
tests/helpers/normalize.js Removed TAPABLE normalization (no longer needed)
tests/helpers/test-server.js Updated comment reference from "jest" to "the test runner"
tests/normalizeOptions.test.ts Removed jest-serializer-path dependency
tests/e2e/*.test.js Updated test APIs from Jest to rstest (fn, spyOn, etc.) and modernized async patterns
tests/e2e/snapshots/*.snap.webpack5 Updated snapshot headers from "Jest Snapshot v1" to "Rstest Snapshot v1" and test name format
tests/fixtures/worker-config-dev-server-false/public/worker-bundle.js Modified formatting
scripts/patch-node-env.cjs Removed Jest-specific environment patch
tests/rstest-env.d.ts Added TypeScript reference for rstest globals

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request migrates the test suite from Jest to rstest. The changes involve updating configurations, dependencies, and test API calls. Overall, the migration looks good, but I've found a few critical issues where an incorrect global rs is used instead of rstest. These will cause tests to fail and need to be addressed.

Copy link

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@9aoy 9aoy requested a review from chenjiahan February 14, 2026 09:02
@chenjiahan chenjiahan merged commit f8f9d7b into main Feb 14, 2026
4 checks passed
@chenjiahan chenjiahan deleted the rstest branch February 14, 2026 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants