Hi I was trying to test the react application With enzyme, But it throws an error TypeError: Adapter is not a constructor , Any Idea
This is my test file
import ProductRow from '../product_row'; import React from 'react'; // import { mount } from 'enzyme'; import * as enzyme from 'enzyme'; import * as Adapter from 'enzyme-adapter-react-16'; enzyme.configure({ adapter: new Adapter() }); test('TodoComponent renders the text inside it', () => { const wrapper = enzyme.mount( <ProductRow item={{}} quickView={[]} productPage={''} count={0} numberOfColumns={0} title={'title'} taxonomies={{}} excerpt={'excerpt'} /> ); });
TypeError: Adapter is not a constructor
I don't think
import *
works as expected when importing a module with a default export, this should work:BTW. you can put the above in a file and reference it in your Jest settings so you don't have to add this to every test:
You need to use the import like this:
This way: (import * as Adapter from ...) returns a message "TypeError: Adapter is not a constructor."
For TypeScript: