Snapshot testing کسی output (عام طور پر UI component کی rendered output یا data structure) کا ایک "snapshot" محفوظ کرتی ہے اور مستقبل کے runs کو اس کے مقابل موازنہ کرتی ہے — جب output بدلتا ہے تو اس کی نشاندہی کرتی ہے۔ یہ غیر ارادی تبدیلیوں کی نشاندہی کے لیے مفید ہے، لیکن اس کی حدود کو سمجھنا ضروری ہے۔
Snapshot testing کیسے کام کرتی ہے
1. First run → the test RECORDS the output (e.g. a rendered component) as a SNAPSHOT file
2. Later runs → COMPARE the current output to the saved snapshot:
→ MATCHES → pass; DIFFERS → fail (the output changed)
3. If the change is INTENTIONAL → UPDATE the snapshot (review the diff, then accept)
(, {
tree = ().();
(tree).();
});
