react-workspaces / react-workspaces-playground

⚛️ 🐈 Zero Config Create-React-App Monorepos with Yarn Workspaces, Lerna and React Storybook.
https://react-workspaces.github.io/react-workspaces-playground/
764 stars 128 forks source link

Error when use shallow in @project/components #34

Closed PicardRaphael closed 4 years ago

PicardRaphael commented 4 years ago

Hello I have a problem when I want to use enzyme shallow for testing the CompOne component located in the workspace @project/components. I have an error about the need of using enzyme-adapter-react-15.

Enzyme Internal Error: Enzyme expects an adapter to be configured, but found none.
To configure an adapter, you should call `Enzyme.configure({ adapter: new Adapter() })`
before using any of Enzyme's top level APIs, where `Adapter` is the adapter
corresponding to the library currently being tested. For example:

         import Adapter from 'enzyme-adapter-react-15';

To find out more about this, see https://airbnb.io/enzyme/docs/installation/index.html

However if I write in the CompOne.test.js file what is in the setupTests it works.

require('jest-prop-type-error');
const enzyme = require('enzyme');
const Adapter = require('enzyme-adapter-react-16');
enzyme.configure({ adapter: new Adapter() });
PicardRaphael commented 4 years ago

For this to work move setupTests to the src folder.