Strategy to test components in React
Hey, I am new into testing and I haven't test anything much before. I am still getting stuck about theory what should I test and what shouldn't. For example here.
I have component
Heading
that takes prop level
which is number between 1 and 6.
Is this test useless? And if so, what test would you write for this specific component?
6 Replies
Theo whole test file looks like so:
I personally dont feel like this test would be giving you much. When I do use tests (which is rarely) it is to bring me confidence in complicated code which I might break now or in the future.
If you feel like this test aids in that goal, then the test isn't useless. If you feel like it doesn't bring you any added error-checking above what you'd just see rendering the website and looking at it with your own eyes, then it might be "useless"
Thanks for you opinion! This is good thought and for my purpose I think it does the thing. I guess tests are very opinionative (at least what should be tested), because it relies on many factors.
This is a great read and still holds up today. I practice this mentality and find myself very confident and safe making rapid and aggressive changes in my codebases and across teams.
For a lot of my projects I find myself prioritizing acceptance tests ensuring the app delivers what’s expected of the product, with a few unit tests sprinkled in where I deem it necessary.
This was a great read! I agree 100% with focusing efforts on integration and even e2e tests