Enzyme and Jest both have different responsibilities "Enzyme" is not a test runner meaning when u enter command npm test
or npm run test
it is jest responsibility that collects all the files ending with .test.js
and run each test case and shows pass and fail results in your console like below
Enzyme provides you function to catch dom element and perform some action below are some of its function
shallow, mount, find, children, etc...
you can also use React Testing Library(another popular testing library) for such function to access dom element
EXTRA: developer often confuse among
- jest
- react-testing-library
- Enzyme
Here Enzyme and react-testing-library are two similar things and alternatives to each other means you can use
- enzyme with jest or
- react-testing-library with jest
- you can also use all three i.e react-testing-library+Enzyme with jest
- but you can not use Enzyme and react-testing-library without jest or any other test runner eg: Mocha
where jest(testing-framework) will collect all .test.js files execute all the test cases and put the output in console with detail like how many pass and fail and react-testing-library or enzyme(both are testing library) will help you to perform event and accessing dom element