{
  "id": "php/phpunit-snapshot-assertion-failure",
  "signature": "PHPUnit 10.5: SnapshotAssertionFailedException: Snapshot \"tests/__snapshots__/UserProfileTest__test_render__1.snap\" does not match the expected snapshot. Use --update-snapshots to update.",
  "signature_zh": "PHPUnit 10.5：快照断言失败异常：快照 \"tests/__snapshots__/UserProfileTest__test_render__1.snap\" 与预期快照不匹配。使用 --update-snapshots 进行更新。",
  "regex": "SnapshotAssertionFailedException: Snapshot \".*\" does not match the expected snapshot",
  "domain": "php",
  "category": "test_error",
  "subcategory": null,
  "root_cause": "The snapshot file on disk differs from the current test output, usually due to an intentional UI change, a dependency update altering rendered HTML, or an accidental modification of the snapshot file.",
  "root_cause_type": "generic",
  "root_cause_zh": "磁盘上的快照文件与当前测试输出不一致，通常是由于有意的UI更改、依赖项更新导致渲染HTML变化，或快照文件被意外修改。",
  "versions": [
    {
      "version": "phpunit/phpunit:10.5.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "spatie/phpunit-snapshot-assertions:5.2.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Deleting the entire __snapshots__ directory and rerunning tests causes all snapshots to be recreated, but this discards the intended baseline for other tests, leading to false positives or missed regressions.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Manually editing the snapshot file to match expected output often introduces formatting inconsistencies (e.g., trailing whitespace, line endings), which can cause the assertion to still fail or produce a different diff.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Running tests with --verbose or --debug without --update-snapshots does not resolve the mismatch; it only provides more output details but does not update the file.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "If the change is intentional, run the test suite with the --update-snapshots flag to overwrite the snapshot file: 'vendor/bin/phpunit --update-snapshots'",
      "success_rate": 0.95,
      "how": "If the change is intentional, run the test suite with the --update-snapshots flag to overwrite the snapshot file: 'vendor/bin/phpunit --update-snapshots'",
      "condition": "",
      "sources": []
    },
    {
      "action": "Inspect the diff using PHPUnit's default output or a tool like 'git diff tests/__snapshots__/' to verify the change is correct, then commit the updated snapshot file.",
      "success_rate": 0.9,
      "how": "Inspect the diff using PHPUnit's default output or a tool like 'git diff tests/__snapshots__/' to verify the change is correct, then commit the updated snapshot file.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If the snapshot is corrupted, restore it from version control: 'git checkout -- tests/__snapshots__/UserProfileTest__test_render__1.snap'",
      "success_rate": 0.85,
      "how": "If the snapshot is corrupted, restore it from version control: 'git checkout -- tests/__snapshots__/UserProfileTest__test_render__1.snap'",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "如果更改是有意的，使用 --update-snapshots 标志运行测试套件以覆盖快照文件：'vendor/bin/phpunit --update-snapshots'",
    "使用 PHPUnit 默认输出或 'git diff tests/__snapshots__/' 等工具检查差异，确认更改正确后，提交更新后的快照文件。",
    "如果快照损坏，从版本控制中恢复：'git checkout -- tests/__snapshots__/UserProfileTest__test_render__1.snap'"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://github.com/spatie/phpunit-snapshot-assertions#updating-snapshots",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2024-03-12",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}