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

chore: use jest.mocked helper in more tests #13117

Merged
merged 2 commits into from
Aug 11, 2022

Conversation

SimenB
Copy link
Member

@SimenB SimenB commented Aug 11, 2022

Summary

Makes for cleaner tests

Test plan

Green CI

const mockSub = sub as jest.MockedFunction<typeof sub>;
const mockSum = sum as jest.MockedFunction<typeof sum>;
const mockSub = jest.mocked(sub);
const mockSum = jest.mocked(sum);
const MockMemory = Memory as jest.MockedClass<typeof Memory>;
Copy link
Member Author

Choose a reason for hiding this comment

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

@mrazauskas Hiya! I cannot use jest.mocked here as it returns jets.MockedObject<typeof Memory> instead of MockedClass. This happens both with @jest/globals and @types/jest (whom I think just copied the implementation from @jest/globals). Any ideas on how we can make jest.mocked work for classes as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep. I encountered this while working on #12727. That PR is fixing this issue. In general the work on types is finished in that PR, it just needs more tests. In this case these are rather complex ones. Indeed it would be nice to land it for Jest 29. I will try to push forward with the tests, if you can wait with the release for a couple of days (;

Copy link
Member Author

Choose a reason for hiding this comment

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

Awesome, thanks! Happy to wait with the release until next week, no rush 🙂

@github-actions
Copy link

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 Sep 11, 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