Skip to content

Conversation

@fi3ework
Copy link
Member

@fi3ework fi3ework commented Nov 26, 2025

Summary

depends on web-infra-dev/rspack#12302.

Related Links

Checklist

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

@netlify
Copy link

netlify bot commented Nov 26, 2025

Deploy Preview for rstest-dev ready!

Name Link
🔨 Latest commit d0fbbf2
🔍 Latest deploy log https://app.netlify.com/projects/rstest-dev/deploys/693b8de7eb0d0a0008168b56
😎 Deploy Preview https://deploy-preview-717--rstest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@fi3ework
Copy link
Member Author

@codex

  1. remove the override in package.json
  2. then run pnpm i && pnpm dedupe to update lock file

@chatgpt-codex-connector
Copy link

Summary

  • Removed the pnpm override for @rspack/core from the workspace configuration in package.json. package.jsonL55-L81

Testing

  • ⚠️ pnpm i (fails: registry returned 403 for @rspack/core)
  • ⚠️ pnpm dedupe (fails: registry returned 403 for axios)

View task →

@fi3ework fi3ework marked this pull request as ready for review December 12, 2025 07:31
Copilot AI review requested due to automatic review settings December 12, 2025 07:31
@fi3ework fi3ework merged commit 1619fc8 into main Dec 12, 2025
16 checks passed
@fi3ework fi3ework deleted the hoist branch December 12, 2025 07:31
Copy link
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 adds support for the rs.hoisted function to the rstest testing framework, which allows users to create hoisted mock functions that can be accessed before module imports are resolved. The feature enables better mock setup patterns by hoisting mock definitions similar to how rs.mock calls are hoisted.

Key changes:

  • Added rs.hoisted API with type definitions and runtime implementation
  • Updated dependency versions including React 19.2.1 → 19.2.3, Rspack 1.6.6 → 1.6.7, and other related packages
  • Added comprehensive e2e tests demonstrating the hoisted functionality

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
pnpm-lock.yaml Updated lockfile with dependency version bumps (React, Rspack, rsdoctor, debug, qs packages)
packages/core/src/types/mock.ts Added type definition for the new hoisted function to RstestUtilities interface
packages/core/src/runtime/api/utilities.ts Added stub implementation for hoisted function; modified resetModules return value
packages/core/src/core/plugins/mockRuntimeCode.js Added webpack runtime code for rstest_hoisted that executes the provided function
packages/core/LICENSE.md Corrected magic-string repository URL (cosmetic fix)
e2e/mock/tests/mockHoist.test.ts Enhanced test to verify @rstest/core can be accessed when imported late
e2e/mock/tests/hoisted.test.ts New test file demonstrating rs.hoisted usage with mock functions
e2e/mock/src/sum.ts Added exports for bar and foo to support new test scenarios
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)

e2e/mock/tests/mockHoist.test.ts:22

  • Callee is not a function: it has type number or undefined.
  c('c');

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

resetModules: () => {
// The actual implementation is managed by the built-in Rstest plugin.
return rstest;
return {} as any;
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

The return value for resetModules has changed from return rstest; to return {} as any;, which breaks the return type consistency. According to the type definition in mock.ts, resetModules should return RstestUtilities to allow method chaining. All other similar methods in this file return rstest to maintain this pattern.

Suggested change
return {} as any;
return rstest;

Copilot uses AI. Check for mistakes.
Comment on lines +87 to +89
hoisted: () => {
// The actual implementation is managed by the built-in Rstest plugin.
return {} as any;
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

The hoisted function implementation returns {} as any but the type signature indicates it should return type T which is the result of calling the provided function fn. This could lead to runtime errors if users rely on the return value. The implementation should call and return the result of fn(), similar to how the webpack runtime code handles it in mockRuntimeCode.js.

Suggested change
hoisted: () => {
// The actual implementation is managed by the built-in Rstest plugin.
return {} as any;
hoisted: <T>(fn: () => T): T => {
// The actual implementation is managed by the built-in Rstest plugin.
return fn();

Copilot uses AI. Check for mistakes.
//#region rs.hoisted
__webpack_require__.rstest_hoisted = (fn) => {
return fn();
};
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

Missing //#endregion comment to close the rs.hoisted region. All other similar regions in this file (rs.unmock, rs.doUnmock, rs.requireActual, rs.mock, rs.mockRequire, rs.doMock, rs.doMockRequire, rs.reset_modules) properly close their regions with //#endregion comments for consistency.

Suggested change
};
};
//#endregion

Copilot uses AI. Check for mistakes.
### magic-string

Licensed under MIT license in the repository at git+https://github.com/Rich-Harris/magic-string.git.
Licensed under MIT license in the repository at https://github.com/rich-harris/magic-string.git.
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

This appears to be a fix to update the repository URL from "git+https://github.com/Rich-Harris/magic-string.git" to "https://github.com/rich-harris/magic-string.git" (note the lowercase username). While this correction improves accuracy, it's unrelated to the PR's stated purpose of adding support for rs.hoisted. Consider addressing this in a separate PR focused on license file maintenance.

Suggested change
Licensed under MIT license in the repository at https://github.com/rich-harris/magic-string.git.
Licensed under MIT license in the repository at https://github.com/Rich-Harris/magic-string.git.

Copilot uses AI. Check for mistakes.

it('@rstest/core should be accessible even if it is imported late, it is specifically hoisted', async () => {
// @ts-expect-error
foo('a', 'b');
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

Callee is not a function: it has type string or undefined.

Copilot uses AI. Check for mistakes.
Copilot AI mentioned this pull request Dec 12, 2025
2 tasks
@9aoy 9aoy mentioned this pull request Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants