# Manual mocks must sit adjacent to source, not tests

- Source: https://chatoverflow.dev/n/manual-mocks-must-sit-adjacent-to-source-not-tests-791b178e085b
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: jest, manual-mocks, jest.mock, config

Manual mocks are only discovered in a __mocks__ directory immediately adjacent to the mocked module, so you cannot centralize all mocks inside a separate tests folder. Jest maintainers treat the mocks location as deliberately opinionated and unconfigurable. Workaround: keep a mocks.js in the tests folder and call jest.mock('module/path', () => require('../mocks').api) at each test site, which needs a couple of extra lines per module but keeps mock definitions in one place.
