Skip to content

test: migrate to Rstest#18

Merged
chenjiahan merged 5 commits intomainfrom
rstest_0314
Mar 14, 2026
Merged

test: migrate to Rstest#18
chenjiahan merged 5 commits intomainfrom
rstest_0314

Conversation

@chenjiahan
Copy link
Copy Markdown
Member

Copilot AI review requested due to automatic review settings March 14, 2026 13:47
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, 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 comprehensive migration of the project's testing framework from Jest to Rstest. The primary goal is to modernize the testing setup, leveraging Rstest's capabilities for improved performance and maintainability. The changes span across configuration files, package scripts, test utility functions, and snapshot formats, ensuring a smooth transition while preserving existing test coverage and behavior.

Highlights

  • Testing Framework Migration: Migrated the project's testing infrastructure from Jest to Rstest, involving significant changes to configuration, scripts, and test utilities.
  • Configuration Updates: Removed the jest.config.js file and introduced a new rstest.config.mjs file to define Rstest's configuration, including test environment, globals, and file patterns.
  • Build Script Refinements: Updated package.json scripts to remove Jest-specific commands and integrate Rstest for running tests, including watch mode.
  • Test Setup Adaptation: Modified setupTest.js to configure Rstest's test timeout and provide compatibility layers for existing 'done-style' asynchronous tests by patching it and test global functions.
  • Snapshot Migration: Migrated existing Jest snapshot files to the Rstest snapshot format, ensuring continuity of snapshot testing.
  • ES Module Conversion: Converted the scripts/globalSetup.js file to an ES module (.mjs) and updated its export syntax.
  • Middleware Test Enhancements: Improved the robustness of middleware.test.js by updating Stats import to ES module syntax, adding a helper for dynamic asset filename retrieval, and using expect.objectContaining for more flexible test assertions.

🧠 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
    • Removed Jest-specific test scripts (test:only, test:coverage).
    • Updated test:watch and test scripts to use Rstest.
    • Removed jest and babel-jest from dev dependencies.
    • Added @rstest/core to dev dependencies.
  • rstest.config.mjs
    • Added new Rstest configuration file, defining test environment, globals, and file inclusion/exclusion patterns.
  • scripts/globalSetup.js
    • Renamed to scripts/globalSetup.mjs.
    • Converted from CommonJS to ES module syntax.
    • Changed anonymous function export to a named setup export.
  • setupTest.js
    • Replaced jest.setTimeout with rstest.setConfig for test timeout configuration.
    • Assigned rstest to globalThis.jest for compatibility.
    • Implemented wrapDoneStyleTest and patchTestApi to support 'done-style' asynchronous tests with Rstest's API, including only, skip, concurrent, and each methods.
  • test/snapshots/logging.test.js
    • Removed old Jest snapshot file.
  • test/snapshots/logging.test.js.snap
    • Added new Rstest snapshot file with updated format.
  • test/logging.test.js
    • Removed Jest test file, implying its content was refactored or integrated into the new Rstest setup.
  • test/middleware.test.js
    • Updated Stats import from CommonJS require to ES module import.
    • Added getAssetFilename helper function to dynamically retrieve asset filenames from compiler stats.
    • Modified expect.toEqual assertions for watch options to use expect.objectContaining for increased test flexibility.
    • Updated immutable cache tests to use the new getAssetFilename helper and ensure main.js is requested before SVG assets.
  • test/utils/snapshots/setupHooks.test.js
    • Removed old Jest snapshot file.
  • test/utils/snapshots/setupHooks.test.js.snap
    • Updated snapshot header and test names to Rstest format.
  • test/utils/snapshots/setupWriteToDisk.test.js
    • Removed old Jest snapshot file.
  • test/utils/snapshots/setupWriteToDisk.test.js.snap
    • Updated snapshot header and test names to Rstest format.
  • test/utils/ready.test.js
    • Updated the expectation for context.logger.info to dynamically use cb.name instead of a hardcoded string, improving test robustness.
Activity
  • The pull request author, chenjiahan, initiated the migration to Rstest.
  • The changes involve a significant refactoring of the testing setup, including configuration, dependencies, and test utilities.
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
Copy Markdown

@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 project's testing framework from Jest to Rstest. The changes include removing Jest's configuration and dependencies, adding the Rstest configuration, and updating test-related scripts and setup files. A compatibility layer has been added to support Jest's done() callback syntax in asynchronous tests, which is a good approach for a smooth migration.

However, I've found a critical issue in package.json where the test script is defined recursively, which will cause an infinite loop.

Additionally, the large test file test/logging.test.js has been removed entirely. Migrating to a new test runner should not result in a reduction of test coverage. This file should be migrated to Rstest instead of being removed.

Copy link
Copy Markdown

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 migrates the test setup from Jest to @rstest/core, updating test bootstrapping, snapshots, and a few test expectations to align with the new runner.

Changes:

  • Replace Jest configuration with rstest.config.mjs and update global test setup (setupTest.js).
  • Update/replace snapshot files to the new snapshot format and namespacing.
  • Adjust a few tests for stability (e.g., less strict option object comparisons; dynamic asset filename selection).

Reviewed changes

Copilot reviewed 14 out of 16 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/utils/ready.test.js Adjusts expectation to use callback function name dynamically.
test/utils/snapshots/setupWriteToDisk.test.js.snap Updates snapshots to new runner’s snapshot format/keys.
test/utils/snapshots/setupWriteToDisk.test.js Removes legacy snapshot artifact file.
test/utils/snapshots/setupHooks.test.js.snap Updates snapshots to new runner’s snapshot format/keys.
test/utils/snapshots/setupHooks.test.js Removes legacy snapshot artifact file.
test/middleware.test.js Updates imports, loosens a few assertions, and makes immutable-asset tests resilient by deriving the emitted SVG name from stats.
test/logging.test.js Removes the logging integration test file.
test/snapshots/logging.test.js.snap Adds new snapshot file for logging tests (but corresponding test file is missing).
test/snapshots/logging.test.js Removes legacy snapshot artifact file.
setupTest.js Replaces Jest timeout setup with rstest config and wraps done-style tests for compatibility.
scripts/globalSetup.mjs Converts global setup to ESM and exports a setup() hook.
rstest.config.mjs Adds rstest configuration (environment, include/exclude, setup/global setup files).
pnpm-lock.yaml Removes Jest deps and adds rstest (and coverage plugin) lock entries.
package.json Updates devDependencies for rstest and modifies test scripts (currently broken).
jest.config.js Removes Jest configuration.

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

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f47d18d9a9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chenjiahan chenjiahan merged commit ab81ca3 into main Mar 14, 2026
5 checks passed
@chenjiahan chenjiahan deleted the rstest_0314 branch March 14, 2026 13:58
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