-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
[Bug]: jest.mocked
function is not exported from jest
object
#12131
Comments
Ah, missed adding it to /cc @k-rajat19 |
Just updated to jest 27.4.4 which includes a fix for this issue but still can't use it as the function isn't in @types/jest? Do we have to wait for it to be added there or is there some other way we're supposed to get TS definitions for jest? |
Hi @cduff would be better if you share what exactly error you are getting while using |
|
Related discussion: DefinitelyTyped/DefinitelyTyped#57716 |
Hi @k-rajat19, I run my jest tests using ts-jest and get jest types from @types/jest as suggested in the official jest documentation. I realise the The DefinitelyTyped/DefinitelyTyped#57716 discussion will hopefully get this resolved. One thing I don't understand though is how anyone can use the new |
You can use |
these test helper are not depend on |
hey @cduff, So for the time being, what you can do is this, since the import { mocked } from 'jest-mock';
@k-rajat19 I agree that it's not dependent on |
@samhwang sorry for being late reply I had not get much time to look here, my exams are going on.
I don't think you explicitly need to import mocked from jest-mock once you imported jest object. |
@k-rajat19 yes it is like you said: it all depends on how jest's types are being interpreted in the first place, honestly. If the jest object is being imported from But the original issue is for when that's not the case (like if you're not working with ESModules/or just transpile into CommonJS anyway), TS will fill in from using |
I don't know why you keep discussing this here - there is absolutely nothing to do in this repo. |
I'm getting an error: https://app.circleci.com/pipelines/github/ike18t/ng-mocks/2810/workflows/cad5fba3-e1c9-4e59-9d20-daf923c60c31/jobs/101406
is it possible that |
Can you open a new issue with a minimal reproduction? |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Version
27.4.3
Steps to reproduce
Try to use
jest.mocked
. E. g.:Expected behavior
jest.mocked
is defined and working.Actual behavior
Error:
TypeError: jest.mocked is not a function
.Also documentation is missing on https://jestjs.io/docs/jest-object, but present in source code: https://github.com/facebook/jest/blob/main/docs/JestObjectAPI.md#jestmockedtitem-t-deep--false
Additional context
jest.mocked
was added in #12089, but seems it was not added tojest
object, and only tojest-mock
package.Tagging author of original PR @k-rajat19
Environment
System: OS: macOS 11.6.1 CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz Binaries: Node: 16.13.0 - /usr/local/bin/node Yarn: 1.22.17 - /usr/local/bin/yarn npm: 8.2.0 - /usr/local/bin/npm npmPackages: jest: ^27.4.3 => 27.4.3
The text was updated successfully, but these errors were encountered: