【发布时间】:2019-06-19 08:48:09
【问题描述】:
使用 react-scripts-ts (2.17.0) 我正在尝试设置一个测试套件。但我收到“SyntaxError: Unexpected identifier”。
这是配置:
tsconfig.json (using the standard of JSX handbook)
{
"compilerOptions": {
"jsx": "react"
}
}
这是组件的布局:
./App.tsx
interface IAppProps extends WithStyles<typeof styles> {
// ...
}
export interface IAppState {
// ...
}
class App extends React.Component<IAppProps, IAppState> {
// ...
}
export default withStyles(styles)(App);
这将是测试设置:
./app.test.ts
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
it('renders without crashing', () => {
const app = React.createElement(App);
const div = document.createElement('div');
ReactDOM.render(app, div);
});
我应该以某种方式运行 Babel 吗?
【问题讨论】:
标签: reactjs jestjs react-scripts