Skip to content
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

Unexpected character # #8497

Closed
palashgupta98 opened this issue May 27, 2019 · 7 comments
Closed

Unexpected character # #8497

palashgupta98 opened this issue May 27, 2019 · 7 comments

Comments

@palashgupta98
Copy link

🐛 Bug Report

A clear and concise description of what the bug is.

I am using private fields in the class and it does not recognize the #

To Reproduce

Steps to reproduce the behavior:

Expected behavior

should have know that this is private field name

A clear and concise description of what you expected to happen.

Link to repl or repo (highly encouraged)

Please provide either a repl.it demo or a minimal repository on GitHub.

https://repl.it/repls/CornsilkMidnightblueGenres

Issues without a reproduction link are likely to stall.

Run npx envinfo --preset jest

Paste the results here:

System:
    OS: Linux 5.0 Ubuntu 19.04 (Disco Dingo)
    CPU: (4) x64 Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
  Binaries:
    Node: 10.15.3 - ~/.nvm/versions/node/v10.15.3/bin/node
    Yarn: 1.16.0 - /usr/bin/yarn
    npm: 6.4.1 - ~/.nvm/versions/node/v10.15.3/bin/npm
  npmPackages:
    jest: 24.7.1 => 24.7.1
@jeysal
Copy link
Contributor

jeysal commented May 27, 2019

You will have to configure Babel to transpile syntax that is not yet supported natively by Node, please check out the docs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@jeysal jeysal closed this as completed May 27, 2019
@musicin3d
Copy link

musicin3d commented Jun 22, 2019

This article (which predates this ticket) suggests that private fields are in-fact supported in the latest version of node.
https://thecodebarbarian.com/nodejs-12-private-class-fields.html

Indeed, I have tested it. I have created a class that has a private field and a method that returns it. I can print it to the console. Yet requiring it in a jest test throws a syntax error.

@musicin3d
Copy link

Here's a small github project that demonstrates the issue. My node version is v12.4.0
https://github.com/musicin3d/jest-bug

@SimenB
Copy link
Member

SimenB commented Jun 22, 2019

This is essentially #6829, just another syntax. You'll need to configure babel or disable babel-jest for this to work

@musicin3d
Copy link

Thank you @SimenB !

Setting transform: {} in jest.config.js did the trick!

@palashgupta98
Copy link
Author

@SimenB yeah, it works! Thanks :-D

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants