Skip to content

docs: add rs.hoisted API documentation#762

Merged
fi3ework merged 5 commits intomainfrom
copilot/update-rs-hoisted-documentation
Dec 12, 2025
Merged

docs: add rs.hoisted API documentation#762
fi3ework merged 5 commits intomainfrom
copilot/update-rs-hoisted-documentation

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 12, 2025

Summary

This PR adds documentation for the rs.hoisted feature that was implemented in PR #717 but was missing documentation.

The rs.hoisted helper function allows creating values that can be accessed in hoisted functions like rs.mock factory functions. It provides access to rs utilities (like rs.fn()) within the hoisted scope, solving the problem of needing to use these utilities within mock factory functions.

Changes Made

  • Added comprehensive documentation for rs.hoisted API including type signature, usage description, and practical example
  • Documentation provided in both English and Chinese versions
  • Fixed all Chinese type label formatting inconsistencies:
    • Changed format from **类型**: to **类型:** (Chinese colon inside bold)
    • Removed redundant English colons and trailing spaces throughout Chinese documentation (changed **类型:**: to **类型:** in 7 locations)

Example Usage

const mocks = rs.hoisted(() => ({
  hoistedFn: rs.fn(),
}));

rs.mock('./sum', () => ({ foo: mocks.hoistedFn }));

it('test', () => {
  mocks.hoistedFn(42);
  expect(mocks.hoistedFn).toHaveBeenCalledWith(42);
});

Related Links

Checklist

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

#717 PR 中,实现了 rs.hoisted 的功能,但是没有更新对应的文档。


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@netlify
Copy link
Copy Markdown

netlify bot commented Dec 12, 2025

Deploy Preview for rstest-dev ready!

Name Link
🔨 Latest commit c5d0395
🔍 Latest deploy log https://app.netlify.com/projects/rstest-dev/deploys/693bd4d8e9dce900082fc103
😎 Deploy Preview https://deploy-preview-762--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.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI and others added 2 commits December 12, 2025 08:19
Co-authored-by: fi3ework <12322740+fi3ework@users.noreply.github.com>
Co-authored-by: fi3ework <12322740+fi3ework@users.noreply.github.com>
Copilot AI requested a review from fi3ework December 12, 2025 08:24
@fi3ework fi3ework marked this pull request as ready for review December 12, 2025 08:28
Copilot AI review requested due to automatic review settings December 12, 2025 08:28
Copy link
Copy Markdown
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 documentation for the rs.hoisted feature that was implemented in PR #717. The rs.hoisted helper function allows creating values that can be accessed in hoisted functions like rs.mock factory functions, solving the problem of needing to use rs utilities (like rs.fn()) within mock factory functions.

Key Changes

  • Added comprehensive documentation for rs.hoisted API including its type signature, usage description, and practical example
  • Documentation provided in both English and Chinese versions

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
website/docs/en/api/rstest/mock-modules.mdx Added English documentation for rs.hoisted including type signature, description, code example, and explanation
website/docs/zh/api/rstest/mock-modules.mdx Added Chinese documentation for rs.hoisted with equivalent content to the English version

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


## rs.hoisted

- **类型**: `<T = unknown>(fn: () => T) => T`
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 formatting of the type label should be - **类型:** (with a Chinese colon inside the bold text) to be consistent with the documentation style used in other files like fake-timers.mdx, mock-functions.mdx, and mock-instance.mdx. Currently it uses - **类型**: (with an English colon outside the bold).

Suggested change
- **类型**: `<T = unknown>(fn: () => T) => T`
- **类型** `<T = unknown>(fn: () => T) => T`

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in ed1bc27 to use - **类型:** format consistent with other documentation files.

@fi3ework
Copy link
Copy Markdown
Member

@copilot make a decent title for this PR.

Co-authored-by: fi3ework <12322740+fi3ework@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Dec 12, 2025

@copilot make a decent title for this PR.

Suggested PR title: docs: add rs.hoisted API documentation

This follows the conventional commit format and clearly describes the change. The work is complete and ready for review.

Copilot AI changed the title [WIP] Update documentation for rs.hoisted feature docs: add rs.hoisted API documentation Dec 12, 2025
@fi3ework
Copy link
Copy Markdown
Member

@copilot search all **类型:**: in Chinese documentation, and replace with **类型:**, that is to say, remove all redundant English colons and the following space char.

Co-authored-by: fi3ework <12322740+fi3ework@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Dec 12, 2025

@copilot search all **类型:**: in Chinese documentation, and replace with **类型:**, that is to say, remove all redundant English colons and the following space char.

Fixed in c5d0395. Replaced all 7 occurrences of **类型:**: with **类型:** in the Chinese mock-modules.mdx documentation, removing redundant English colons and trailing spaces.

@fi3ework fi3ework enabled auto-merge (squash) December 12, 2025 08:44
@fi3ework fi3ework merged commit 669a6d2 into main Dec 12, 2025
28 of 29 checks passed
@fi3ework fi3ework deleted the copilot/update-rs-hoisted-documentation branch December 12, 2025 08:45
@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.

4 participants