Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(jest-mock): align behaviour and return type of generateFromMetadata method #13207

Merged
merged 3 commits into from
Sep 3, 2022
Merged

fix(jest-mock): align behaviour and return type of generateFromMetadata method #13207

merged 3 commits into from
Sep 3, 2022

Conversation

mrazauskas
Copy link
Contributor

Split from #13202

Summary

Current return type of generateFromMetadata method of ModuleMocker is Mock<T>. That is the type of jest.fn(), but not of a mocked module. This PR implements Mocked<T> as the return type.

Few more internal types got cleaned up. For instance, it appeared that I was misusing UnknownFunction type previously.

Test plan

Type tests added.

@@ -7,7 +7,7 @@

/* eslint-disable local/ban-types-eventually, local/prefer-rest-params-eventually */

export type MockFunctionMetadataType =
export type MockMetadataType =
Copy link
Contributor Author

@mrazauskas mrazauskas Sep 2, 2022

Choose a reason for hiding this comment

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

Having Function in this and MockFunctionMetadata type is misleading. Sounds like they are related with mock functions, but in fact these are definitions for mocked modules / objects. Might be helpful to change the names for future readers.

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

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

awesome work 👍

@SimenB
Copy link
Member

SimenB commented Sep 3, 2022

@github-actions
Copy link

github-actions bot commented Oct 4, 2022

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants