Skip to content
This repository has been archived by the owner on Apr 26, 2022. It is now read-only.

ydcjeff/sunappu

Repository files navigation

Sunappu (スナップ)

ci deno module deno doc

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')
})

LICENSE

MIT