I was trying to do unit testing for a react component. But when I tried to render it using TestUtils.renderIntoDocument()
method jest throws an error
Error: Line 1: Unexpected token ILLEGAL
at constructError (node_modules/esprima/esprima.js:2406:21)
at createError (node_modules/esprima/esprima.js:2425:17)
at unexpectedTokenError (node_modules/esprima/esprima.js:2500:13)
at throwUnexpectedToken (node_modules/esprima/esprima.js:2504:15)
at scanPunctuator (node_modules/esprima/esprima.js:842:13)
at advance (node_modules/esprima/esprima.js:1621:16)
at lex (node_modules/esprima/esprima.js:1690:78)
at expect (node_modules/esprima/esprima.js:2520:21)
at parseFunctionSourceElements (node_modules/esprima/esprima.js:4827:9)
at parseFunctionExpression (node_modules/esprima/esprima.js:5073:16)
Poiting to nowhere inmy code. So I tried removing elements one by one and figured that the image component might be causing the probelm.
<span><input type="image" title="cc" src={require('../../assets/images/cc.png') }></input></span>
saw an almost similer issue happened in react-native in this post. If anybody can show some light on it. It will be great.!
Thanks