-
-
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
Jest does not support private class fields #9022
Comments
I've found a workaround for this. In my Jest config, I'm disabling Babel transpilation completely using transformIgnorePatterns: module.exports = {
testEnvironment: "node",
transformIgnorePatterns: ['.*']
}; |
The workaround doesn't seem to work with the coverage flag |
The problem (and therefore the solution) is the babel configuration in jest. and then add a config file
|
Yup, either disable It's unfortunate babel/babel#7660 never went anywhere |
@SimenB I think that PR went somewhere with v25.3.0 |
Yeah, this has been fixed since my comment |
I can see it works but I can't still test them in my suites. How do you deal with #method is not defined? |
That's a question for StackOverflow, not this issue tracker |
Also there is an important point for jest runs with |
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. |
#8497 🐛 Bug Report
When using Jest with a class that has private fields (introduced in Node.js 12), the tests fail with a syntax error – “unexpected character '#'”
To Reproduce
Prerequisites
Steps to reproduce the behavior
Clone this repository: https://github.com/technology-ebay-de/zapperment
Checkout branch jest-issue:
Install npm dependencies:
Change directory to workspace backend:
cd packages/backend
Run tests:
yarn test
The console shows the following error:
If you delete line 7 in the module
SceneBuilder.js
, the tests run without error.Expected behavior
No error, Jest should support private class fields with the
#
syntax, since they can be used in Node.js 12 without flags or transpilers.Link to repl or repo
See steps to reproduce above:
envinfo
The text was updated successfully, but these errors were encountered: