HoukasaurusRex / boilerplate-express-ts-server

A Best Practices™️ Express.js and Typescript server with clustering and socket.io
https://perfect-express-ts-server.herokuapp.com/
MIT License
4 stars 1 forks source link

Test files - file structure #4

Open TNieminen opened 4 years ago

TNieminen commented 4 years ago

If all unit tests are behind one folder with dot notation, don't we end up in a rather long list of files which is not that friendly to search?

tests
  |
  -unit
      |
      logger.test.ts
      many-other-files.tets.ts
      .....

I would argue for discover-ability having tests close to what they are testing (especially unit tests) make sense.

For integration tests it might make more sense to have them on the upper level, because they are testing the collaboration of many modules.

HoukasaurusRex commented 4 years ago

Yeah I've been back and forth with this one. On the one hand, it's really easy to imagine unit tests next to the "unit" they're testing. It's easy to remember to do, a reference for when you update that unit, and overall fairly convenient. The problem is that there's no file associated with each integration test, since they're

testing the collaboration of many modules

I think it's too confusing to try to support both strategies, so I opted for the more recognizable system to keep things consistent at least

TNieminen commented 4 years ago

I understand the point and I think it makes sense. It's more important to have consistency.