JSX: Unexpected token
See original GitHub issuehi!
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:
- Created 7 years ago
- Comments:20 (11 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 😭
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.