Developers can't mock two modules that share a file name, like two index.js files, in different folders.
JavaScript developers who write Jest tests with manual mocks
Where it stands
- Sourced (done)
- Kit (done)
- Wanted (next)
- Building
- Solved
How this problem came to be
- Found1 sourcegithub.com/jestjs
- Quoted5 claimseach checked against its page
- BriefWrittenand what solved looks like
- Market2 signals220 reactions on the issue
- Kit6 steps22 tools · 6 routes
- People0 want0 live it · 0 would test
The problem, broken down
- Who it hurts
- Jest users who write manual mocks for modules that have the same file name in different directories
- The moment
- Jest shows a duplicate manual mock warning, or the mock file is ignored and the real module is used instead.
- What people do today
- Developers rename their non-test files so each name is unique, which the source calls a workaround.
- Why it's unsolved
- The source says manual mocks are matched by base name across the project. Changing that is a breaking change, and the Jest maintainer says internal Facebook code depends on the current behavior.
- What solved looks like
- Two manual mocks with the same file name in different folders both work, and each one replaces the module next to it.
Evidence lens
Every claim points at the quote it rests onSources
Claims
Builders still need to know
- How do Jest users who hit this problem want node module mocks to be placed, given the shared root __mocks__ folder?
- Would a config option that switches the matching rule be enough for teams, or do they need a full redesign?
- How many projects have hit this clash, and how do they currently work around it?
Drafted with claude-haiku-5-5 from the cited source and published automatically. Every quote was checked against the source.
Sources
From a public page with a citation.
What the source says, in short
Jest shows a duplicate manual mock warning, or the mock file is ignored and the real module is used instead. Developers rename their non-test files so each name is unique, which the source calls a workaround. The source says manual mocks are matched by base name across the project. Changing that is a breaking change, and the Jest maintainer says internal Facebook code depends on the current behavior.
Forks 0
Nobody has forked this yet. Be the first.
Market read
How big this is, from the evidence
- npm registry ↗Our estimate · Low confidenceAbout 61 million Jest downloads a week on npm“"downloads":61298221”
- GitHub ↗Builders' pull · Medium confidence220 reactions on the issue
How these were measured: The npm registry counted 61,298,221 downloads of jest from 29 October to 4 November 2026. Downloads include automated builds and are not people, and this is the upper bound of use, not the number who hit duplicate mock names. Total reactions on the GitHub issue, read from its API.
For whoever takes this up
The builder's path for this problem
A path written for this problem: its open questions, who to talk to, its data and its ideas, with tools for each stage and a starter prompt ready to paste into any assistant.
Open the pathDiscussion 0
No comments yet.