@bes/snap

Simple snapshot utility used in boilreact

Stats

stars šŸŒŸissues āš ļøupdated šŸ› created šŸ£size šŸ‹ļøā€ā™€ļø
@bes/snap
Minified + gzip package size for @bes/snap in KB

Readme

Snap

Simple testing snapshot utility used in boilreact

$ npm i @bes/snap --save-dev

Usage

const snap = require('@bes/snap')({
  outputDir: './tests/_snapshots/html',
  outputFile: './tests/_snapshots/snap.json'
});

snap({
  numId:'000',
  mess:'Hello, World!',
  body:'<h1>Hello, World!</h1>'
});

snap({
  numId:'001',
  mess:'Boom',
  body:'<span>Boom</span>'
});

Idea

It works similarly to jest snapshot but with less magic. The idea is to create a file e.g. snap.json where the snapshot info will be saved.

{
  "000": {
    "numId": "000",
    "mess": "Hello, World!"
  },
  "001": {
    "numId": "001",
    "mess": "Boom"
  }
}

This while in a new directory saving the data themselves.

_snapshots
ā”œā”€ā”€ html
ā”‚Ā Ā  ā”œā”€ā”€ 000.html
ā”‚Ā Ā  ā””ā”€ā”€ 001.html
ā””ā”€ā”€ snap.json

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.