2.2.0 • Published 3 months ago

unexpected-snapshot v2.2.0

Weekly downloads
161
License
BSD-3-Clause
Repository
-
Last release
3 months ago

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

3 months ago

2.1.0

2 years ago

2.0.0

2 years ago

1.2.0

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.8.0

4 years ago

0.7.1

4 years ago

0.7.0

4 years ago

0.6.0

5 years ago

0.5.0

5 years ago

0.4.0

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.0

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago