4 ms·
I know how to make tests for _logic_, that's usually in Typescript functions (e. g., React hooks). But for components, that call some of those hooks and then r
by Scarblac 3y ago
I know how to make tests for _logic_, that's usually in Typescript functions (e. g., React hooks).
But for components, that call some of those hooks and then render some JSX, I've never been able to write a test that found a bug later on. Every single time one of them failed, either the change made was so large that the whole build failed to compile anyway, or it was because there was new desired behaviour and the test needed changing, not the code.
If a type of test doesn't help find bugs, it's a waste of space.
- latchkey 3y agoI've given an example of a whole repository, that is now 4 years old, full of the types of tests you're talking about. It isn't that hard. If the desired behavior is changing, then the test should fail and yes, you need to rewrite it. That's how testing works.
- Scarblac 3y agoIt's not hard, but they just make the build of our monorepo take longer and longer without finding actual bugs, in my experience. I feel most unit tests should be commented out once the thing under test is done.
- latchkey 3y agoYou are arguing against tests. It is not a winnable argument.
- Capricorn2481 3y agoNo, people are arguing against frontend tests because they're orthogonal to test driven development
- latchkey 3y agoI really don't understand this comment at all.