snapshot testing companion for node:test
npm install @matteo.collina/snapsnapshot testing companion for node:test.
```
npm i @matteo.collina/snap
`js
import Snap from '@matteo.collina/snap'
import { test } from 'node:test'
import { deepEqual } from 'node:assert/strict'
const snap = Snap(import.meta.url)
test('a snapshot', async (t) => {
const actual = await (await fetch('http://example.com')).text()
const snapshot = await snap(actual)
deepEqual(actual, snapshot)
})
`
On the first execution, the snapshot will be taked and stored in
the .snapshots folder in the same directory of package.json.
To update the snapshot, run with the SNAP_UPDATE=1 env variable set.
`js
const Snap = require('@matteo.collina/snap')
const { test } = require('node:test')
const { deepEqual } = require('node:assert/strict')
const snap = Snap(__filename)
test('a snapshot', async (t) => {
const actual = await (await fetch('http://example.com')).text()
const snapshot = await snap(actual)
deepEqual(actual, snapshot)
})
``
MIT