I am trying to configure testing frameworks to test react components but no matter what I try I get some errors. Steps to reproduce:
create-react-app react-test
npm i enzyme enzyme-adapter-react-16 react-test-renderer
-
Inside
src
foldertouch setupTests.js
and past the following code into itimport { configure } from 'enzyme'; import Adapter from 'enzyme-adapter-react-16'; configure({ adapter: new Adapter() });
-
npm run test
with either default create-react-app test or shallow-rendering test
I get this error in terminal
react-component-testing@0.1.0 test /Users/dimitry/Desktop/github/react-component-testing react-scripts test --env=jsdom
module.js:515 throw err; ^
Error: Cannot find module '/Users/dimitry/Desktop/github/react-component-testing/node_modules/jest -cli'
Thanks for any help and useful advice!
/EDIT/ Removing pacakage-lock.json
, yarn.lock
and node-modules
and reinstalling all packages solves the issue, but I am not sure if this workaround is appropriate one in this case.
Aucun commentaire:
Enregistrer un commentaire