Skip to content

يدعم مُشغل اختبارات Bun اختبار اللقطات على غرار Jest عبر .toMatchSnapshot().

ts
import { test, expect } from "bun:test";

test("لقطة", () => {
  expect({ foo: "bar" }).toMatchSnapshot();
});

في المرة الأولى التي يتم فيها تنفيذ هذا الاختبار، سيقوم Bun بكتابة ملف لقطة إلى القرص في دليل يسمى __snapshots__ يوجد بجانب ملف الاختبار.

txt
test
├── __snapshots__
│   └── snap.test.ts.snap
└── snap.test.ts

لإعادة إنشاء اللقطات، استخدم العلم --update-snapshots.

sh
bun test --update-snapshots
txt
test/snap.test.ts:
✓ snapshot [0.86ms]

 1 pass
 0 fail
 snapshots: +1 added # تم إعادة إنشاء اللقطة
 1 expect() calls
Ran 1 tests across 1 files. [102.00ms]

راجع الوثائق > مُشغل الاختبارات > اللقطات للحصول على الوثائق الكاملة للقطات مع مُشغل اختبارات Bun.

Bun بواسطة www.bunjs.com.cn تحرير