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

[heft]: The mocked helper from @types/heft-jest might be unnecessary #3609

Closed
mrazauskas opened this issue Aug 31, 2022 · 5 comments
Closed

Comments

@mrazauskas
Copy link

Summary

If I get it right, the purpose of @types/heft-jest is to provide mocked() helper. Seems like code was copied from ts-jest.

The fact is that it was moved to jest (from v28) and removed from ts-jest completely. Now this is jest.mocked().

Perhaps it is time to deprecate @types/heft-jest package? And to tweak Heft documentation as well?

Details

I am not a user of Heft, but I have put some effort to rework jest.mocked() and to add jest.Mocked<T> recently. So I am interested to inform Jest user about these improved/new APIs. Could not figure out which version of Jest ships with Heft. These are the links to Jest v29 (latest):

jest.Mocked<T>: https://jestjs.io/docs/mock-function-api/#jestmockedsource

jest.mocked(): https://jestjs.io/docs/mock-function-api/#jestmockedsource-options

Standard questions

Please answer these questions to help us investigate your issue more quickly:

Question Answer
@rushstack/heft version? latest
Operating system? n/a
Would you consider contributing a PR? Yes
Node.js version (node -v)? 18
@iclanton
Copy link
Member

@octogonz - you originally put this together. Thoughts?

@iclanton
Copy link
Member

We don't support Jest 28 yet, but we should soon.

@octogonz
Copy link
Collaborator

octogonz commented Sep 1, 2022

@octogonz - you originally put this together. Thoughts?

HBO was using this API. @elliot-nelson can you comment on the impact of removing it? How much work would be required to fix up your tests?

@mrazauskas
Copy link
Author

mrazauskas commented Sep 1, 2022

We don't support Jest 28 yet, but we should soon.

I see. So my idea might be premature.

Just to add more detail. Jest v27.4 shipped with jest.mocked() helper added. Jest v29 has reworked jest.mocked() and jest.Mocked* utility types added. These all are Jest's built-in APIs, not through @types/jest or ts-jest.

@elliot-nelson
Copy link
Collaborator

@octogonz I believe we are on Jest 27.0, and we are using the mocked() global construct and not jest.mocked().

But if the work is "switch to jest.mocked() the next time you do a Heft upgrade that moves from Jest 27 to Jest 28", it sounds totally fine to me -- especially if it lets us drop an extra package. (Not sure if you're saying that's all @types/heft-jest is doing or not.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

4 participants