question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JSX: Unexpected token

See original GitHub issue

hi!

I’m using example of ‘jest’ configuration from readme.md and this simple test

const renderer = require('react-test-renderer')

it('renders correctly', () => {
  const tree = renderer.create(<div>hi!</div>).toJSON()
  expect(tree).toMatchSnapshot()
})

gives the next Error:

   var tree = renderer.create(<div>hi!</div>).toJSON();
                                   ^
    SyntaxError: Unexpected token <

      at transformAndBuildScript (node_modules/jest-runtime/build/transform.js:285:10)
      at process._tickCallback (internal/process/next_tick.js:103:7)

Any ideas? I’d be grateful.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:20 (11 by maintainers)

github_iconTop GitHub Comments

7reactions
stephenotaloracommented, Dec 23, 2018

was there any resolution about this? I’m getting a similar error where I get a Syntax error while trying to use jsx within my tests 😭

1reaction
kulshekharcommented, Sep 16, 2016

That is used by the part of the preprocessor that takes care of displaying the correct line numbers in the typescript files. If you remove this, any failed tests you see will show you the line numbers in the compiled JS file.

Read more comments on GitHub >

github_iconTop Results From Across the Web

babel-loader jsx SyntaxError: Unexpected token [duplicate]
I found a weird error in my hello world web app. I'm using babel-loader in webpack to help me convert jsx into js,...
Read more >
[Bug]: Unexpected Token '<' error in jsx · Issue #13926 - GitHub
Current and expected behavior. this code works in babel-loader 7.1.5 but i had to update all my babel dependencies and it gave me...
Read more >
Uncaught SyntaxError: Unexpected token in JSX
I am using Parcel to build my React app. It's throwing a syntax error: unexpected token. HTML: <!DOCTYPE html> <html lang="en"> <head> <meta ......
Read more >
Why JSX part is causing syntax error - Render community
Why JSX part is causing syntax error: unexpected token error while deploying? ... The JSX part is causing error as: SyntaxError: dist/client/src/ ...
Read more >
JavaScript : babel-loader jsx SyntaxError: Unexpected token
JavaScript : babel-loader jsx SyntaxError: Unexpected token [ Gift : Animated Search Engine : https://bit.ly/AnimSearch ] JavaScript ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found