Please refere to the following GIST for further instructions
Code sandbox: https://codesandbox.io/s/core-concepts-and-styling-evtvz
-
Using
create-react-app, what do we need to set up for testing? A:create-react-appcomes withJestandreact-testing-libraryby default, but in order forJestto locate them they need to have one of the following conventions:- Files with
.jssuffix in__tests__folders, files with.test.jsor.spec.js. Jest can also be paired with other testing libraries/utilities like Enzyme but those must me installed usingyarn addornpm install.
- Files with
-
What components are worth to test in your development? A: In my opinion it would be components that have some kind of interaction that can be mimicked and function used.
-
Can you apply TDD once you already created components? A: Yes, the concept of TDD is to test first (create failing test) then make those test pass and finally refactor, so when adding new change to that component one can start using TDD, providing little by little more more of the TDD advantages. TDD is a cycle that is best done in chunks.