diff --git a/packages/jest-snapshot/src/State.ts b/packages/jest-snapshot/src/State.ts index bc06574b5842..0403a96129ac 100644 --- a/packages/jest-snapshot/src/State.ts +++ b/packages/jest-snapshot/src/State.ts @@ -36,7 +36,7 @@ export type SnapshotMatchOptions = { readonly inlineSnapshot?: string; readonly isInline: boolean; readonly error?: Error; - readonly matchOnly?: boolean; + readonly testFailing?: boolean; }; type SnapshotReturnOptions = { @@ -198,7 +198,7 @@ export default class SnapshotState { inlineSnapshot, isInline, error, - matchOnly = false, + testFailing = false, }: SnapshotMatchOptions): SnapshotReturnOptions { this._counters.set(testName, (this._counters.get(testName) || 0) + 1); const count = Number(this._counters.get(testName)); @@ -234,7 +234,7 @@ export default class SnapshotState { // In pure matching only runs, return the match result while skipping any updates // reports. - if (matchOnly) { + if (testFailing) { if (hasSnapshot && !isInline) { // Retain current snapshot values. this._addSnapshot(key, expected, {error, isInline}); diff --git a/packages/jest-snapshot/src/index.ts b/packages/jest-snapshot/src/index.ts index 5192903955f0..d4e8a3ab8f26 100644 --- a/packages/jest-snapshot/src/index.ts +++ b/packages/jest-snapshot/src/index.ts @@ -281,17 +281,7 @@ const _toMatchSnapshot = (config: MatchSnapshotConfig) => { /** If a test was ran with `test.failing`. Passed by Jest Circus. */ const {testFailing = false} = context; - /** - * Run the snapshot matcher as a normal throwing matcher with - * no side effects and no error supression. - * - * Skipped side effects occur in {@link snapshotState.match} - * and include updating the snapshot and recording passed/failed - * snapshots in the snapshot state. - */ - const matchOnly = testFailing; - - if (!matchOnly && context.dontThrow) { + if (!testFailing && context.dontThrow) { // Supress errors while running tests context.dontThrow(); } @@ -375,8 +365,8 @@ const _toMatchSnapshot = (config: MatchSnapshotConfig) => { error: context.error, inlineSnapshot, isInline, - matchOnly, received, + testFailing, testName: fullTestName, }); const {actual, count, expected, pass} = result;