Skip to content

Commit

Permalink
Explain example
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Dec 6, 2020
1 parent 1b2f198 commit 9d37eb3
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const {toMatchInlineSnapshot} = require('jest-snapshot');
expect.extend({
async toMatchObservationInlineSnapshot(fn, ...args) {
this.error = new Error();
// This specific behavior can be implemented without a custom matcher.
// In a real example one might want to observe some global value that `fn()` is affecting.
// The difference between before and after `fn()` might then be persisted as a snapshot.
const result = await fn();

return toMatchInlineSnapshot.call(this, result, ...args);
Expand Down

0 comments on commit 9d37eb3

Please sign in to comment.