Conversation
✅ Deploy Preview for rstest-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the type system for rs.mock and rs.doMock methods by allowing a Promise<T> as the first parameter to provide better TypeScript type inference and IDE support. The enhancement extracts the type T from the Promise and uses it to type the factory function's return value as Partial<T>.
- Updated type signatures to accept
string | Promise<T>as the first parameter - Added comprehensive test coverage for the new typed argument feature
- Updated documentation in both English and Chinese to explain the new functionality
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/core/src/types/mock.ts | Updated type definitions for mock methods to support Promise as first argument and improved type safety |
| tests/mock/tests/mockTypedArg.test.ts | Added comprehensive tests demonstrating the new typed argument functionality |
| tests/mock/src/*.ts | Added explicit type annotations to exported constants for better type inference |
| website/docs/*/api/rstest/mockModules.mdx | Updated documentation to explain the new Promise parameter support |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
9aoy
approved these changes
Jul 24, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rs.mockandrs.doMockalso support passing aPromise<T>as the first parameter, and use the typeTas the return value type of the second factory function after awaiting (Promise<T>). This provides better type hints in IDEs and type validation for the factory function's return value. PassingPromise<T>only enhances type hints and has no impact on the module mocking capabilities.Related Links
Checklist