{"record":{"id":"34ba2d7f4b8d09d3","repo":"avajs/ava","slug":"no-snapshot-available-new-snapshots-are-not-crea","errorCode":null,"errorMessage":"No snapshot available — new snapshots are not created in CI environments","messagePattern":"No snapshot available — new snapshots are not created in CI environments","errorType":"exception","errorClass":"AssertionError","httpStatus":null,"severity":"error","filePath":"lib/assert.js","lineNumber":681,"sourceCode":"\n\t\t\t\tthrow fail(new AssertionError(message ?? 'Could not compare snapshot', {\n\t\t\t\t\tasssertion: 't.snapshot()',\n\t\t\t\t\timproperUsage,\n\t\t\t\t}));\n\t\t\t}\n\n\t\t\tif (result.pass) {\n\t\t\t\treturn pass();\n\t\t\t}\n\n\t\t\tif (result.actual) {\n\t\t\t\tthrow fail(new AssertionError(message ?? 'Did not match snapshot', {\n\t\t\t\t\tassertion: 't.snapshot()',\n\t\t\t\t\tformattedDetails: [formatDescriptorDiff(result.actual, result.expected, {invert: true})],\n\t\t\t\t}));\n\t\t\t} else {\n\t\t\t\t// This can only occur in CI environments.\n\t\t\t\tthrow fail(new AssertionError(message ?? 'No snapshot available — new snapshots are not created in CI environments', {\n\t\t\t\t\tassertion: 't.snapshot()',\n\t\t\t\t}));\n\t\t\t}\n\t\t});\n\n\t\tthis.truthy = withSkip((actual, message) => {\n\t\t\tassertMessage(message, 't.truthy()');\n\n\t\t\tif (actual) {\n\t\t\t\treturn pass();\n\t\t\t}\n\n\t\t\tthrow fail(new AssertionError(message, {\n\t\t\t\tassertion: 't.truthy()',\n\t\t\t\tformattedDetails: [formatWithLabel('Value is not truthy:', actual)],\n\t\t\t}));\n\t\t});\n","sourceCodeStart":663,"sourceCodeEnd":699,"githubUrl":"https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/lib/assert.js#L663-L699","documentation":"AVA throws this AssertionError from t.snapshot() when no snapshot exists for the assertion (result.actual is falsy) and AVA is running in a CI environment, where new snapshots are never written. This is deliberate: in CI AVA must verify against committed snapshots rather than silently creating new ones, so a missing snapshot is a hard failure instead of an auto-update.","triggerScenarios":"Calling t.snapshot(value) in CI for a test/argument combination that has no recorded snapshot — new snapshot assertion added without updating .snap files, new test file, or a .snap file not committed to the repo — while AVA detects CI (CI=true or AVA_CI_MODE).","commonSituations":"Developer added t.snapshot() locally, ran tests (snapshots generated locally, not committed) and pushed before committing .snap; CI cache/prune rules exclude *.snap files; running the suite in CI before ever running it locally; .snap files gitignored by a broad ignore rule.","solutions":["Run npx ava --update-snapshots locally to create the snapshots, then commit the generated .snap files and push again.","Verify .snap files under test/snapshots/ are tracked by git and not matched by .gitignore rules.","If snapshots should not be used in this environment, remove the t.snapshot() call or guard it, since CI will never create new snapshots.","Ensure the CI job runs the same test files/paths as local so snapshot lookups match."],"exampleFix":"// before (CI log)\n// AssertionError: No snapshot available — new snapshots are not created in CI environments\n\n// after (local)\nnpx ava --update-snapshots\ngit add test/snapshots/*.snap\ngit commit -m \"add snapshots\" && git push","handlingStrategy":"validation","validationCode":"// Locally, before pushing:\n// 1. npx ava --update-snapshots\n// 2. verify snapshots are tracked:\n//    git ls-files 'test/snapshots/*.snap'\nconst {execSync} = require('node:child_process');\nconst tracked = execSync(\"git ls-files 'test/snapshots/*.snap'\").toString().trim();\nif (!tracked) throw new Error('No .snap files committed — CI will fail with \"No snapshot available\"');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always run the tests locally (with snapshot creation) before pushing to CI.","Ensure *.snap files are git-added and not excluded by .gitignore or CI cache prune rules.","Remember CI never creates snapshots; treat 'No snapshot available' as 'commit your snapshots'.","Keep local and CI test file paths identical so snapshot lookups resolve the same entries."],"tags":["snapshot","ava","ci","missing-snapshot"],"backgroundTag":"missing-snapshot-file","analyzedSha":"bbfd946322fdeca2b547a691d947fb4e18c0c67f","analyzedAt":"2026-09-02T01:24:43.834Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}