create-react-app: Unexpected token in App.test.js
See original GitHub issueEnvironment
-
node -v
: v8.11.1 -
npm -v
: 5.6.0 -
npm ls react-scripts
(if you haven’t ejected): react-scripts@1.1.4 -
Operating system: [MacOS 10.13.5]
Steps to Reproduce
$ create-react-app test
open up workspace with extension installed In the output for the test (next to terminal/debug console/problems) see output:
FAIL src/App/App.test.js
● Test suite failed to run
/path/to/project/App/App.test.js: Unexpected token (7:18)
5 | it('renders without crashing', () => {
6 | const div = document.createElement('div');
> 7 | ReactDOM.render(<App />, div);
| ^
8 | ReactDOM.unmountComponentAtNode(div);
9 | });
10 |
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 0.157s
Ran all test suites related to changed files.
Expected Behavior
Jest test passes when run by extension
Actual Behavior
Jest tests fail when run by extension
Issue Analytics
- State:
- Created 5 years ago
- Reactions:20
- Comments:14 (1 by maintainers)
Top Results From Across the Web
Create-React-App build - "Uncaught SyntaxError: Unexpected ...
When I deploy without changing any default settings, I will get this "Uncaught SyntaxError: Unexpected token <" error and nothing shows up on ......
Read more >Fix "Jest encountered an unexpected token" with "create-react ...
Here are a few ways I have seen, assume the package is being used @fullcalendar : Use a customized package react app customize-cra...
Read more >SyntaxError: Unexpected token '<' on new build of React
I have a React application and every time I deploy it to digital ocean I'm getting this error SyntaxError: Unexpected token '<' ,...
Read more >How To Fix Unexpected Token Error for NPM Package in react ...
Are you getting this error with react -leaflet or other packages. If you are then it's most likely related to babel and there...
Read more >[Solved]-Jest with Create React App: Test suite failed to run
[Solved]-Jest with Create React App: Test suite failed to run - Unexpected token-Reactjs ... These configs you can find after you do npm...
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
This issue still exists as of 9/21/19
I think I found a temporary workaround:
package.json
(keys “jest” and “babel”)Now it’s running properly for me. Here is what I finally added to my
package.json
:I’m not sure everything is required, but it’s juste copy-pasta from ejected project, I didn’t want to bother fine-tuning.