首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >通过react-scripts-ts进行测试时出现‘语法:意外标识符’错误

通过react-scripts-ts进行测试时出现‘语法:意外标识符’错误
EN

Stack Overflow用户
提问于 2019-06-18 16:46:31
回答 1查看 108关注 0票数 0

使用react-scripts-ts (2.17.0),我尝试设置一个测试套件。但是我收到了一个"SyntaxError:意外的标识符“。

配置如下:

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吗?

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56645129

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档