Sunappu (スナップ)
Simple Snapshot Assertion in Deno using
JSON.stringify
Usage
Snapshot files are saved as ES Modules with named exports in the __snapshots__
directory.
This module needs --allow-read
and --allow-write
runtime flag of Deno.
For snapshot updating, delete the snapshot file and regenerate it for now.
// import from deno.land/x
import { setupSnapshot } from 'https://deno.land/x/sunappu@<version>/mod.ts';
// setup Snapshot file to write/read
// argument should be always `import.meta.url`.
const assertSnapshot = await setupSnapshot(import.meta.url);
Deno.test('...', () => {
const actual = ...
// call the function for snapshot assertion
// the second argument is used as the named export in the snapshot file
assertSnapshot(actual, 'test something')
})