Skip to content

Tests - Where to place? #435

Answered by illright
azinit asked this question in Q&A
Feb 2, 2022 · 4 comments · 2 replies
Discussion options

You must be logged in to vote

TL;DR: Put them in segments next to the code that they are testing.


There are no restrictions in FSD as to where you can place your tests. The two common configurations are

  1. co-locating tests with the code that they are testing
  2. having a separate folder that mirrors the structure of src and only contains tests

From the point of view of FSD, the first approach is more preferable, since one of the main benefits of FSD is low coupling, so that changes to one aspect of the project happen in one small subfolder, not one file per folder across all folders. This can be achieved by placing your tests in a spec`` or tests/` folder inside each segment. Mocks can be stored in that folder as well.

F…

Replies: 4 comments 2 replies

Comment options

azinit
Feb 2, 2022
Maintainer Author

You must be logged in to vote
1 reply
@azinit
Comment options

azinit Feb 2, 2022
Maintainer Author

Comment options

azinit
Feb 2, 2022
Maintainer Author

You must be logged in to vote
0 replies
Comment options

azinit
Feb 13, 2022
Maintainer Author

You must be logged in to vote
1 reply
@azinit
Comment options

azinit Feb 13, 2022
Maintainer Author

Comment options

You must be logged in to vote
0 replies
Answer selected by illright
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants