14 Matching Annotations
- Jul 2022
-
github.com github.com
-
Interestingly, Rails doesn't see this in their test suite because they set this value during setup:
-
- Nov 2021
-
www.varvet.com www.varvet.com
-
I am firmly convinced that asserting on the state of the interface is in every way superior to asserting on the state of your model objects in a full-stack test.
-
- Jun 2021
-
docs.gitlab.com docs.gitlab.com
-
Do not test the internal implementation of the child components:
-
- Mar 2021
-
trailblazer.to trailblazer.to
-
There’s no need to test controllers, models, service objects, etc. in isolation
Tags
- testing: tests should resemble the way your software is used
- unnecessary
- testing: avoid unnecessarily testing things in too much isolation, in a different way than the code is actually used (should match production)
- isolation (programming)
- testing: avoid testing implementation details
Annotators
URL
-
- Jul 2020
-
rails.lighthouseapp.com rails.lighthouseapp.com
-
It would be nice if the tests weren't so implementation specific, but rather tested the essence of the functionality. I tried to make them less brittle but failed. To that end, re-writing all the tests in rspec would be (IMHO) a brilliant improvement and pave the way for better tests in the future and more flexibility in implementation.
-
- Nov 2019
-
kentcdodds.com kentcdodds.com
-
it doesn't even render in-file components. For example, the <Fade /> component we have above is an implementation detail of the <HiddenMessage /> component, but because we're shallow rendering <Fade /> isn't rendered so changes to that component could break our application but not our test. That's a major issue in my mind and is evidence to me that we're testing implementation details.
-
The reason this kind of test fails those considerations is because it's testing irrelevant implementation details. The user doesn't care one bit what things are called. In fact, that test doesn't even verify that the message is hidden properly when the show state is false or shown when the show state is true. So not only does the test not do a great job keeping us safe from breakages, it's also flakey and doesn't actually test the reason the component exists in the first place.
-
I could rename toggle to handleButtonClick (and update the corresponding onClick reference). My test breaks despite this being a refactor.
-
I could mistakenly set onClick of the button to this.tgogle instead of this.toggle. My test continues to work, but my component is broken.
-
Will this test break when there's a mistake that would break the component in production?Will this test continue to work when there's a fully backward compatible refactor of the component?
-
-
kentcdodds.com kentcdodds.com
-
-
Why is testing implementation details bad?There are two distinct reasons that it's important to avoid testing implementation details. Tests which test implementation details:Can break when you refactor application code. False negativesMay not fail when you break application code. False positives
-
-
kentcdodds.com kentcdodds.com
-
But far too often, I see tests which are testing implementation details (read this before continuing if you haven't already). When you do this, you introduce a third user. The developer user and the end user are really all that matters for this component. So long as it serves those two, then it has a reason to exist. And when you're maintaining the component you need to keep those two users in mind to make sure that if you break the contract with them, you do something to handle that change.But as soon as you start testing things which your developer user and end user don't know or care about (implementation details), you add a third testing user, you're now having to keep that third user in your head and make sure you account for changes that affect the testing user as well.
-
-
testing-library.com testing-library.com
-
You want to write maintainable tests for your React components. As a part of this goal, you want your tests to avoid including implementation details of your components and rather focus on making your tests give you the confidence for which they are intended. As part of this, you want your testbase to be maintainable in the long run so refactors of your components (changes to implementation but not functionality) don't break your tests and slow you and your team down.
-