I'm a little confused about a dependency. I see in the package.json of jest (at its GitHub site) that it depends on react-test-renderer. But the version of jest I get with create-react-app doesn't have this dependency. It seems I have to install react-test-renderer myself in order to implement snapshot tests. Should I have to do that?
It is already mentioned in the documents. https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#testing-components
May be it helps!
Thanks! I guess my confusion is that if I install Jest on its own, I will get react-test-renderer. So why is it that when I use create-react-app which install Jest for me, I do not get react-test-renderer?
I guess my confusion is that if I install Jest on its own, I will get react-test-renderer.
You will not get react-test-renderer if you install Jest, it must be installed separately.
I see in the package.json of jest (at its GitHub site) that it depends on react-test-renderer.
Jest is a monorepo, meaning the root package.json has zero significance in the big picture of things.
Hope this helps!
Jest has react-test-renderer in devDependencies. It鈥檚 because they use it for their own integration testing (namely, to make sure it works with Jest nicely). However react-test-renderer itself is completely independent of Jest, and is a part of React, just like react-dom. So you need to install it if you want to use it.
Most helpful comment
Jest has
react-test-rendererindevDependencies. It鈥檚 because they use it for their own integration testing (namely, to make sure it works with Jest nicely). Howeverreact-test-rendereritself is completely independent of Jest, and is a part of React, just likereact-dom. So you need to install it if you want to use it.