News for hackers. Stuff that matters.
Re:Delightful React file/directory structure by d357r0y3r on Tuesday March 15, 2022 @11:35AM (#30686610)
I think people do the "separate directory for tests" thing because test runners have, in the past, shipped with a default configuration to target a test directory, rather than match test files by suffix.

Colocation of test files is the hands down winner and encourages the writing of tests. When you're making a change to a code file, you probably won't think to scour the codebase for relevant tests. If you see the test file right next to source file in your editor, you probably will.

Re:Delightful React file/directory structure by zelphirkalt on Tuesday March 15, 2022 @12:19PM (#30687212)
When you make a change to a code file, you should run your tests. Why else do you have them? A test failure should result in you going to fix that or, if appropriate, change assumptions of the test. I don't see how it is harder to add tests either.
Re:Delightful React file/directory structure by Jernik on Tuesday March 15, 2022 @04:05PM (#30690801)
What about changes that don't cause test failures? A really quick one I can think of is a pure addition. Lets say you have tests for Feature A in 3 places. You add a thing to Feature A, and find 2 places where Feature A is tested, add tests to those, feel like you did your due diligence and move on. Co-located tests would fix this problem
Re:Delightful React file/directory structure by azemetre on Tuesday March 15, 2022 @12:40PM (#30687483)
It's not that it's impossible to test, it's just more of "out of sight, out of mind." Couple this with a poor engineering culture in general, it's easier for me to understand how this pattern encourages very poor testing.