【发布时间】:2020-11-25 17:05:45
【问题描述】:
我在这个 repo 中重新创建了问题:
https://github.com/umarmw/lopital-sdk
在执行lerna run test时,会抛出这个错误:
FAIL __tests__/doctor.test.js
● Test suite failed to run
SyntaxError: /codebox/lopital-sdk/packages/doctor/__tests__/doctor.test.js: Support for the experimental syntax 'jsx' isn't currently enabled (9:24):
7 | describe('doctor', () => {
8 | it('should be selectable by class "foo"', function() {
> 9 | expect(shallow(<Doctor title="MO" />).is('.btn-doctor')).toBe(true);
| ^
10 | });
11 |
12 | it('should mount in a full DOM', function() {
Add @babel/preset-react (https://git.io/JfeDR) to the 'presets' section of your Babel config to enable transformation.
If you want to leave it as-is, add @babel/plugin-syntax-jsx (https://git.io/vb4yA) to the 'plugins' section to enable parsing.
我已经在 babel 预设中添加了这个@babel/preset-react,但这并没有解决问题。
有什么想法吗?
【问题讨论】:
-
你也安装了
@babel/preset-react吗? -
您是否尝试将格式更改为
jsx? -
@yaya,我试过了……但还是不行。
-
@Rashomon,它是一个打字稿项目。扩展名应该是 ts 或 tsx。
标签: reactjs jestjs babeljs lerna