Package detail

@japa/snapshot

japa7.5kMIT2.0.8

Snapshot testing plugin for Japa

japa, snapshot, snapshot-testing

readme

@japa/snapshot

Snapshot testing plugin for Japa

[![gh-workflow-image]][gh-workflow-url] [![npm-image]][npm-url] license-image

Snapshot testing plugin for Japa. This plugin allows you to write snapshot tests for your application.

Complete API documentation

Installation

Install the package from the npm registry as follows:

npm i @japa/snapshot

pnpm i @japa/snapshot

yarn add @japa/snapshot

Usage

You can use this package with the @japa/runner as follows.

import { snapshot } from '@japa/snapshot'
import { configure } from '@japa/runner'

configure({
  plugins: [snapshot()],
})

Once done, you will be able to use the 2 new matchers added, either on expect or assert

test('test title', ({ expect, assert }) => {
  // with @japa/assert
  assert.snapshot('1').match()

  // with @japa/expect
  expect('1').toMatchSnapshot()
})

[gh-workflow-url]: https://github.com/japa/snapshot/actions/workflows/checks.yml 'Github action'

[npm-url]: https://www.npmjs.com/package/@japa/snapshot/v/latest 'npm'