TypeError: Cannot read property 'configure' of undefined
FrancisVila opened this issue · comments
Francis Vila commented
Hi,
Thanks for sharing this adapter. I get the following error:
The following test generates an error TypeError: Cannot read property 'configure' of undefined
import { shallow, Enzyme } from 'enzyme'
import Groot from './Groot'
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
Enzyme.configure({ adapter: new Adapter() });
it('works', () => {
const wrap = shallow(
<Groot name='Groot' />
)
expect(wrap.text()).toEqual('I am Groot')
})
My package.json file:
{
"name": "axwayprerequisites",
"homepage": ".",
"version": "0.1.0",
"private": true,
"dependencies": {
"@babel/core": "^7.12.9",
"@material-ui/core": "^4.11.2",
"axios": "^0.21.1",
"babel-eslint": "^10.1.0",
"bootstrap": "^4.5.3",
"dompurify": "^2.2.0",
"env-cmd": "^10.1.0",
"enzyme": "^3.11.0",
"eslint": "^7.15.0",
"is-regex": "^1.1.2",
"jest-environment-jsdom-sixteen": "^1.0.3",
"jquery": "^3.5.1",
"logrocket": "^1.0.14",
"react": "^17.0.1",
"react-bootstrap": "^1.4.0",
"react-contextmenu": "^2.14.0",
"react-csv": "^2.0.3",
"react-dom": "^17.0.1",
"react-hook-form": "^6.9.6",
"react-scripts": "4.0.0",
"react-select": "^3.1.0",
"react-tabs": "^3.1.1",
"react-test-renderer": "^17.0.1",
"react-three-state-checkbox": "^1.3.4",
"request": "^2.88.2",
"web-vitals": "^0.2.4"
},
"scripts": {
"start": "react-scripts start",
"start:local": "env-cmd -f ./.env.local react-scripts start",
"start:testlocal": "env-cmd -f ./.env.testlocal react-scripts start",
"start:test_remoteserver_localclient": "env-cmd -f ./.env.test_remoteserver_localclient react-scripts start",
"test": "react-scripts test --env=jest-environment-jsdom-sixteen",
"eject": "react-scripts eject",
"build": "env-cmd -f ./.env.local react-scripts build",
"build:local": "env-cmd -f ./.env.local react-scripts build",
"build:prod": "env-cmd -f ./.env.prod react-scripts build",
"build:remoteTestServer": "env-cmd -f ./.env.remoteTestServer react-scripts build",
"toto": "env-cmd -f ./.env.toto node toto.js"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"@wojtekmaj/enzyme-adapter-react-17": "^0.3.2"
}
}
Wojciech Maj commented
import Enzyme, { shallow } from 'enzyme'
?
Francis Vila commented
Thank you so much! That works.