我正在尝试设置玩笑来测试我的反应代码。
但我在以下行的 这是我的.babelrc文件android.intent.action.MY_PACKAGE_REPLACED
迫切需要帮助。
更清楚地说,这是我的fake.spec.js。在导入语句中,我面临意外的令牌导入。 class app extends Component <State> {
{
"presets": [
"@babel/preset-env",
"@babel/preset-react"
]
}
这是我的package.json
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();
});
});
这是我要测试的app.react.js文件
{
"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"
}
}
答案 0 :(得分:0)
您的代码看起来像TypeScript,因此将@babel/preset-typescript
中的presets
添加到.babelrc
中。
哦,那您就不需要preset-env
。