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
Variables with names starting with mock
are not considered when hoisting jest.mock()
calls
#5448
Comments
mock
are not hoistedmock
are not considered when hoisting jest.mock()
calls
I am also running this package on large test bases and need the ts-jest style of hoisting. Any ideas on how to make this work like ts-jest? |
Just came across this problem too. Without this feature working correctly it makes certain test scenarios either very difficult or impossible. |
As for my own workaround, I used |
@kj455 are you applying There's not many issues open on this repo, but 3 or 4 of them are currently to do with this mocking problem. It seems like a serious limitation. Is there no update from the maintainers? |
Couple of months later and this still seems to be a major problem with no acknowledgement... |
this is swc/core upstream regression it seems, worked fine last time I tried (^1.2.160) @kdy1 can you please check? |
thanks @wight554 can confirm reverting to "@swc/core": "1.2.160", has got me switched away from ts-jest |
Same issue, confirming the error is gone when downgrading to "@swc/core": "1.2.160" (was on 1.2.232) |
.swcrc:
package.json
|
I have the same issue while migrating a jest testing project from
|
Any updates on this? Can confirm this is still an issue with @swc/jest 0.2.29. |
Please see #5205 |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
With
babel-jest
it seems likejest.mock()
calls are hoisted to the top of the file.swc
seems to have this transformation as well, so no issue with that.The problem occurs when the
jest.mock()
calls depends on other variable, for instance:With
babel
, this code works fine becausejest
makes an exception for variables with names starting withmock
. Withswc
, it seems like this isn't the case and we end up with the following error:Quoting this comment from ts-jest repo: kulshekhar/ts-jest#1088 (comment)
The text was updated successfully, but these errors were encountered: