Trying to setup AVA after running create-react-app. There are a few tutorials and references of this gist I've found and tried, but I keep getting an unexpected token
error on the JSX <App />
element. Anyone know what is wrong with that gist? Full output of npm run test
:
react-with-ava@0.1.0 test /react-with-ava
cross-env NODE_ENV=test ava
1 exception
Uncaught Exception
SyntaxError: /react-with-ava/src/App.test.js: Unexpected token (8:18)
SyntaxError: /react-with-ava/src/App.test.js: Unexpected token (8:18)
6 | test('renders without crashing', t => {
7 | const div = document.createElement('div');
8 | ReactDOM.render(<App />, div);
| ^
9 | });
It is neither supported nor recommended to use Ava with Create React App.
The created project already contains a test runner (Jest) which we recommend to use. Run npm test
in the project folder to start.
In theory you could get Ava to work but this would require configuring Babel which will get confusing in a CRA project very quickly. If you insist on using Ava you can npm run eject
and then replace Jest with Ava manually in the ejected project.