I am trying to set up jest to test my react code. but i am running into the above error, at the < for state in below line
class app extends Component <State> {
this is my .babelrc file
{
"presets": [
"@babel/preset-env",
"@babel/preset-react"
]
}
need help desperately. to be more clear this is my fake.spec.js. in the import statement i am facing a unexpected token import.
import React from 'react';
import app from '../src/app.react.js';
describe('App Snapshot', () => {
test('renders', () => {
const component = renderer.create(
<app />
);
let tree = component.toJSON();
expect(tree).toMatchSnapshot();
});
});
this is my package.json
{
"name": "app",
"version": "0.1.0",
"private": true,
"dependencies": {
"@babel/preset-react": "^7.0.0",
"@material-ui/core": "^1.5.0",
"axios": "^0.18.0",
"babel-preset-react": "^6.24.1",
"chart.js": "^2.7.2",
"jest": "^24.1.0",
"js-cookie": "^2.2.0",
"material-icons": "^0.2.3",
"qrcode.react": "^0.9.2",
"react": "^16.4.2",
"react-chartjs-2": "^2.7.4",
"react-dom": "^16.4.2",
"react-router-dom": "^4.3.1",
"react-scripts": "^1.1.4",
"universal-cookie": "^3.0.4",
"unix-timestamp": "^0.2.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "jest",
"eject": "react-scripts eject"
},
"devDependencies": {
"@babel/cli": "^7.2.3",
"@babel/core": "^7.3.4",
"@babel/preset-env": "^7.3.4",
"flow-bin": "^0.78.0"
}
}
this is my file what i am trying to test app.react.js
import React, {Component} from 'react';
import 'themes/material/material.css';
import {graphql} from 'lib/graphql'
class app extends Component <State> {
state = {
app_config: {
name: null,
logo_image: null,
};
...