samedi 29 février 2020

React: Trying to mirror __tests__/ with src/

I want to have my __tests__/ mirror the src/. I am able to run the tests, but they are all failing with the same error below:

/application/src/setup.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import Enzyme from 'enzyme';
                                                                                             ^^^^^^

    SyntaxError: Cannot use import statement outside a module

setup.js

import Enzyme from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'

Enzyme.configure({ adapter: new Adapter() })

The file structure for my project is as follows (__tests__/ mirrors src/) :

application/
  __tests__/
   App.test.js
   components/
    c.test.js
  src/
   components/
    c.js
   styles/
   App.js
   jest.config.js
   setup.js

I specifically do not want to move my __test__/ into src/ and keep the structure as is, any help is appreciated!

Aucun commentaire:

Enregistrer un commentaire