enzyme: TypeError: Adapter is not a constructor

For TypeScript:

import { configure } from 'enzyme';
import * as ReactSixteenAdapter from 'enzyme-adapter-react-16';
const adapter = ReactSixteenAdapter as any;
configure({ adapter: new adapter.default() });

You need to use the import like this:

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

This way: (import * as Adapter from ...) returns a message "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:

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

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

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:

setupFiles: ['<rootDir>/tools/jest/setup-react-adapter.js'],