unexpected-snapshot

Add inline snapshotting powers to the Unexpected assertion library

BSD-3-Clause 21 个版本
安装
npm install unexpected-snapshot
yarn add unexpected-snapshot
pnpm add unexpected-snapshot
bun add unexpected-snapshot
README

unexpected-snapshot

NPM version Build Status Coverage Status

Snap!

Unexpected plugin for capturing and matching inline snapshots.

An assertion that matches against a snapshot looks almost like a regular to equal assertion:

const expect = require('unexpected')
  .clone()
  .use(require('unexpected-snapshot'));

expect(something, 'to equal snapshot', 'the value');

expect(somethingElse, 'to equal snapshot', { foo: 123 });

There's a string-based variant for values that involve non-trivial object trees:

function Person(name) {
  this.name = name;
}

expect(
  new Person('Eigil'),
  'to inspect as snapshot',
  "Person({ name: 'Eigil' })"
);

Specify the UNEXPECTED_SNAPSHOT=yes environment variable to update the snapshots for the tests that fail.

Tip: You can easily make an initial recording by leaving out the 3rd argument:

expect(something, 'to equal snapshot');

Note that this recording/injection feature only works when running your tests in node.js. The matching against the snapshot works in all test runners, including the browser.

RELEASES

See the changelog.

版本列表
2.2.0 2024-01-23
2.1.0 2022-05-31
2.0.0 2022-04-23
1.2.0 2021-07-01
1.1.1 2020-12-10
1.1.0 2020-11-19
1.0.2 2020-04-13
1.0.1 2020-04-13
1.0.0 2020-02-07
0.8.0 2020-01-07
0.7.1 2019-12-11
0.7.0 2019-11-24
0.6.0 2019-06-17
0.5.0 2019-06-14
0.4.0 2019-06-14
0.3.2 2019-06-14
0.3.1 2019-05-25
0.3.0 2019-05-23
0.2.0 2017-08-07
0.1.1 2017-08-04
0.1.0 2017-08-04