проблема с babel при запуске jest в репозитории lerna reactjs - PullRequest
1 голос
/ 05 августа 2020

Я воссоздал проблему в этом репо:

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/preset-react в предустановку babel, но это не решает проблему.

Есть идеи?

1 Ответ

1 голос
/ 06 августа 2020

Я исправил указанную выше проблему, добавив babel.config.json в каждую папку пакета, поскольку lerna будет пытаться выполнить код, относящийся к каждому пакету.

...