My take is that similarly to the distinction between ‘src’ and ‘dist’ folders, which serve completely different purposes, ‘test’ should be another top-level folder. Separation of concerns. Clearer for onboarding devs as well
Where should test files go? If you vote, please reply with your reasoning
-
-
-
I've flipped on this myself. Used to prefer /test but started working on projects in the last ~year that co-locate and finding it quite nice. Especially typescript where it's nice to have a single /src folder for all files you compile.
-
to be fair, the new Typescript project references stuff might make this better.
End of conversation
New conversation -
-
-
You missed: inside your source code https://doc.rust-lang.org/book/second-edition/ch11-03-test-organization.html#the-tests-module-and-cfgtest …
-
*last panel expanding mind meme*
End of conversation
New conversation -
-
-
_inside_ source files unless your language is terrible. I'm calling out 100% of interpreted languages here.
-
Fair. if (process.env.NODE_ENV === "test") { ... } :p
-
Yes... the problem is that every byte shipped to Lambda has a coldstart cost. I'm not even sure how to skip those lines with Babel or webpack but once you use either, one might as well write in another language

-
Why write typescript if you can just WASM your Golang?
-
heh. Maybe someday, but right now that still feels like a pretty big leap. I don't mind JS the language (even without TS) and I'm already gonna webpack my code for server and client. It is the responsible thing to do.
-
Maybe I'm just JavaScripting wrong but most times I write it, I'm actually writing C++ Node Addons
End of conversation
New conversation -
-
-
Integration tests in test directory, unit tests next to source files
-
I like it!
End of conversation
New conversation -
-
-
For node modules it’s easier to npmignore them if in a separate directory. For node in general, it’s also just more common
-
Good point about npmignore. I used to feel more strongly about that. All those tests bloating my lambda zips :) I see a shift happening on the browser/application side. Lots more tests adjacent to the source.
End of conversation
New conversation -
-
-
It's more convenient to run and maintain tests on one folder tree. Also you do find and replace in tests differently than in production code.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
looks like the community thinks you should do bothpic.twitter.com/RSTTzvCN46
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
Clojure, particularly clojure.spec, makes test coexistence with source code very natural. It also makes repl-driven development easy, because you’re just bouncing between one file and the interpreter.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
Inside the source files! Check out doctest: https://docs.python.org/2/library/doctest.html …
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
Unit tests are nice near the source files as you might want to check the test to understand what that code is meant to do.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.