{"id":"72a73fea1df6e1ba","repo":"jestjs/jest","slug":"jest-couldn-t-locate-all-inline-snapshots","errorCode":null,"errorMessage":"Jest: Couldn't locate all inline snapshots.","messagePattern":"Jest: Couldn't locate all inline snapshots\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/jest-snapshot/src/utils.ts","lineNumber":428,"sourceCode":"      ({type}) => type === 'TemplateLiteral' || type === 'StringLiteral',\n    );\n\n    const {snapshot} = inlineSnapshot;\n    remainingSnapshots.delete(snapshot);\n    const replacementNode = templateLiteral(\n      [templateElement({raw: escapeBacktickString(snapshot)})],\n      [],\n    );\n\n    if (snapshotIndex === -1) {\n      args.push(replacementNode);\n    } else {\n      args[snapshotIndex] = replacementNode;\n    }\n  });\n\n  if (remainingSnapshots.size > 0) {\n    throw new Error(\"Jest: Couldn't locate all inline snapshots.\");\n  }\n};\n","sourceCodeStart":410,"sourceCodeEnd":431,"githubUrl":"https://github.com/jestjs/jest/blob/f49721c78e195558b40913977c9230f5b7f559d8/packages/jest-snapshot/src/utils.ts#L410-L431","documentation":"Thrown by `traverseAst` (utils.ts:427-429) after walking the AST if `remainingSnapshots` is non-empty - i.e. at least one inline snapshot recorded by the test run could not be matched to a `CallExpression` in the parsed source. Jest collected snapshots to write during the run but cannot find where to write at least one of them.","triggerScenarios":"The test source on disk no longer contains the matcher call (file edited while tests run), the matcher is invoked through a dynamically-constructed callee the AST traversal cannot recognize (e.g. `expect(x)[methodName]()` with a computed property), or the matcher was imported under an aliased/different name not literally present at the call site.","commonSituations":"IDE auto-save rewrites the test file mid-run; using a custom matcher name re-exported from another module (the patcher only recognizes names literally present in the AST per the CLAUDE.md note); a macro or codegen step produces the call at runtime but not in source; race between parallel test runs writing the same file.","solutions":["Re-run the test suite once the file is stable on disk (no concurrent edits).","Avoid renaming/re-exporting the snapshot matcher; call `toMatchInlineSnapshot`/`toThrowErrorMatchingInlineSnapshot` by their literal names at the call site.","Avoid computed member access (`expect(x)[dynamicName]()`) for snapshot assertions.","If the call lives in a shared helper, inline it or move to `toMatchSnapshot()` (file-based, no AST patching)."],"exampleFix":"// before: matcher imported under an alias invisible to the patcher\nimport { toMatchInlineSnapshot as snap } from '@jest/expect';\nexpect(value).snap();\n// after\nexpect(value).toMatchInlineSnapshot();","handlingStrategy":"validation","validationCode":"// Verify every InlineSnapshot call has a literal callee property name in source\nconst ast = babel.parseSync(source, { filename });\nlet ok = true;\ntraverse(ast, {\n  CallExpression(p) {\n    const callee = p.node.callee;\n    if (callee.type === 'MemberExpression' && /InlineSnapshot$/.test(callee.property.name || '') && callee.computed)\n      ok = false;\n  },\n});\nif (!ok) throw new Error('inline snapshot called via computed/aliased name');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Call toMatchInlineSnapshot/toThrowErrorMatchingInlineSnapshot by literal name at the call site.","Don't re-export or alias the snapshot matchers.","Don't edit the test file while a run is in progress; disable format-on-save during -u runs."],"tags":["jest-snapshot","inline-snapshot","ast","user-error"],"analyzedSha":"f49721c78e195558b40913977c9230f5b7f559d8","analyzedAt":"2026-08-03T20:16:28.571Z","schemaVersion":2}