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

BabylonParser (jest-editor-support) fails with JSX #3070

Closed
etiennedi opened this issue Mar 5, 2017 · 3 comments
Closed

BabylonParser (jest-editor-support) fails with JSX #3070

etiennedi opened this issue Mar 5, 2017 · 3 comments

Comments

@etiennedi
Copy link

etiennedi commented Mar 5, 2017

File: jest/packages/jest-editor-support/src/parsers/BabylonParser.js

tl;dr: We're manually including one babylon plugin, but I think we should include all plugins.


Long version:

I've been using orta's great vscode-jest extension and noted that it doesn't work correctly on spec files containing JSX. So have others. I could trace the issue back to the parse function in jest-editor-support.

Babylon will not be able to parse JSX with the default configuration. I noticed we are manually adding the flow plugin, but not the JSX plugin. Since Babylon 6.14.1 we could simply include all available plugins.

So instead of:

const plugins = Array.isArray(babel.plugins)
  ? babel.plugins.concat(['flow'])
  : ['flow']

We could simply do:

const plugins = Array.isArray(babel.plugins)
  ? babel.plugins.concat(['*'])
  : ['*']

I've tested locally and this fixes my JSX issue.

Update: See the commit I added to the fork. The new test scenario I added wouldn't pass before. It does with the change. Hope you agree, then I'll send the PR.

@cpojer
Copy link
Member

cpojer commented Mar 6, 2017

Yeah this sounds good. Would you mind sending a PR for this? :)

@etiennedi
Copy link
Author

etiennedi commented Mar 6, 2017

Great. Completed the CLA and sent the PR. :)

@cpojer cpojer closed this as completed in cec138b Mar 6, 2017
skovhus pushed a commit to skovhus/jest that referenced this issue Apr 29, 2017
)

* change babylon plugins to all, fixes jestjs#3070

* increase minimum required babylon version for new features to work
tushardhole pushed a commit to tushardhole/jest that referenced this issue Aug 21, 2017
)

* change babylon plugins to all, fixes jestjs#3070

* increase minimum required babylon version for new features to work
@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 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants