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
The code with private class fields is crashing when executing with Jest with error:
>npx jest test
FAIL test/index.test.js
β Test suite failed to run
SyntaxError: F:\_\WebstormProjects\jestBug\src\index.js: Unexpected character '#' (4:2)
2 |
3 | class C {
> 4 | #x = 42;
| ^
5 | x() {
6 | return this.#x;
7 | }
at Parser.raise (node_modules/@babel/parser/lib/index.js:6387:17)
at Parser.readToken_numberSign (node_modules/@babel/parser/lib/index.js:6716:12)
at Parser.getTokenFromCode (node_modules/@babel/parser/lib/index.js:7062:14)
at Parser.nextToken (node_modules/@babel/parser/lib/index.js:6587:12)
at Parser.next (node_modules/@babel/parser/lib/index.js:6527:10)
at Parser.eat (node_modules/@babel/parser/lib/index.js:6532:12)
at Parser.expect (node_modules/@babel/parser/lib/index.js:7690:10)
at Parser.parseClassBody (node_modules/@babel/parser/lib/index.js:10670:10)
at Parser.parseClass (node_modules/@babel/parser/lib/index.js:10645:22)
at Parser.parseStatementContent (node_modules/@babel/parser/lib/index.js:9942:21)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 2.434s
Ran all test suites matching /test/i.
I recommend following babel/babel#7660 which I think is the only non ad hoc solution to this
I've read that issue but got no idea what should I do... can you explain it a little bit about how to support Node.js features with Jest without transpiling?
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.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.
π Bug Report
The code with private class fields is crashing when executing with Jest with error:
But direct run of the file under test works fine:
To Reproduce
Steps to reproduce the behavior:
src/index.js
test/index.test.js
npx jest test
Expected behavior
Should have no error
Link to repl or repo (highly encouraged)
https://github.com/Alexsey/jestBug
envinfo
The text was updated successfully, but these errors were encountered: