Test file placement
Status
Accepted.
Context
ADR 0014 decided that vitest is used for testing. It still has to be decided where tests are placed.
Vitest supports in-source testing, i.e. tests that live inside the module they test, next to the implementation. This is not possible for component tests or end-to-end tests.
Decision
- Unit tests are written as in-source tests within the module they test.
- Component tests are written in a separate file next to the component, i.e., in the same folder, e.g.
Fullscreen.spec.tsnext toFullscreen.ce.vue. - End-to-end tests are placed in a dedicated
e2efolder.
Consequences
- (+) Unit tests are close to the implementation, which makes them easier to find and keep up to date.
- (+) Private functions can be tested without exporting them only for testing purposes.
- (+) The kind of a test can be derived from its location.
- (o) In-source tests have to be stripped from the production build.
- (-) Implementation files become longer.