Create-react-app: react-test-renderer not included

Created on 23 Apr 2017  路  4Comments  路  Source: facebook/create-react-app

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?

question

Most helpful comment

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.

All 4 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

onelson picture onelson  路  3Comments

alleroux picture alleroux  路  3Comments

fson picture fson  路  3Comments

alleroux picture alleroux  路  3Comments

JimmyLv picture JimmyLv  路  3Comments