From 9d37eb3ad153e1e1794991bf44bd2ee0998d83e6 Mon Sep 17 00:00:00 2001 From: eps1lon Date: Sun, 6 Dec 2020 18:39:30 +0100 Subject: [PATCH] Explain example --- .../__tests__/asynchronous.test.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/e2e/custom-inline-snapshot-matchers/__tests__/asynchronous.test.js b/e2e/custom-inline-snapshot-matchers/__tests__/asynchronous.test.js index a195e3f49780..1d148d769950 100644 --- a/e2e/custom-inline-snapshot-matchers/__tests__/asynchronous.test.js +++ b/e2e/custom-inline-snapshot-matchers/__tests__/asynchronous.test.js @@ -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);