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
@hanjunspirit I think I have a similar problem. How did you debug it? How did you get the compiled code? I think in my case also the order of the statements is somehow mixed up. Although I import the class definition on top of the file I get the following error:
ReferenceError: Cannot access 'Base' before initialization
I'm a little bit lost because I don't know how to debug and therefore I can not create a repo with reproduction and without a repo I can not create a bug report.
If someone else has the same problem, we found a workaround that works for us (probably that's not possible in every project).
We were able to reference the problematic file in setupFiles (https://jestjs.io/docs/configuration#setupfiles-array) and now everything works as expected. For us, this is a good enough workaround because it unblocks us 🎉 and we can continue to work.
Nevertheless, a long-term solution would be better than a workaround. We also expect that the hoisting "feature" of jest breaks our code. It's super hard to create a repo that reproduces the problem. We think that our problem is very similar to what @hanjunspirit encountered.
Version
27.1.5
Steps to reproduce
for the code:
Expected behavior
Actual behavior
It will be compiled into:
This leads to Base class not being found, causing an error.
Debug log
Additional context
This piece of code has different results in different versions of Node.js:
[1,2,3].sort(() => 1)
For example,
in Node.js 10.24.0, it returns
[3, 2, 1]
,But in Node.js 12.18.3, it returns
[1, 2, 3]
This depends on the implementation of the sort algorithm, and the result is unstable.
So for the sort in hoist-jest(#3498), if all isJestGlobalImport and isHoistableStatement return false, it might reversing all statements.
Environment
The text was updated successfully, but these errors were encountered: