You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I hope this issue contains all the information. Let me know if a reproducible git repo would be helpful to narrow down the problem. Thank you!
The text was updated successfully, but these errors were encountered:
smvv
changed the title
Jest commonjs gives ReferenceError: Cannot access before initialization when jest.mock and exoprrted class
Jest commonjs gives ReferenceError: Cannot access before initialization when jest.mock and exported class
Nov 3, 2023
I haven't tested it myself. Have you tried manually editing the statement order of the swc compiled files?
If it is feasible, It's better to send a feature request to https://github.com/swc-project/plugins/tree/main/packages/jest , since it is related to import hoisting and this repository focuses on the mutability of export.
I've read #79 but I think I'm seeing a related issue.
minimal reproducible code
There are two input source files:
The swc config used for transforming TS to JS in jest is:
The tsc config is:
tsc transpiled
Test output:
swc transpiled
Test output:
Notes
SWC version info:
Tsc generates this import order:
while swc generates:
Could that ordering be an issue that causes the runtime error?
I'm using the jest preset
ts-jest
with a custom transformer (to allow switching at runtime usingTS_LOADER
between tsc and swc).Could a jest plugin like this hoisting of mock calls be related?
I hope this issue contains all the information. Let me know if a reproducible git repo would be helpful to narrow down the problem. Thank you!
The text was updated successfully, but these errors were encountered: