From e9a61c3ae6eebe7c0018fd9b1bcee6037768f04f Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Tue, 24 Dec 2024 18:54:48 +0900 Subject: [PATCH] fix(snapshot): fix obsolete `toMatchSnapshot("...")` of skipped tests --- packages/snapshot/src/port/state.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/snapshot/src/port/state.ts b/packages/snapshot/src/port/state.ts index 89e777e4155f..8fb02b1fca3b 100644 --- a/packages/snapshot/src/port/state.ts +++ b/packages/snapshot/src/port/state.ts @@ -109,7 +109,10 @@ export default class SnapshotState { markSnapshotsAsCheckedForTest(testName: string): void { this._uncheckedKeys.forEach((uncheckedKey) => { - if (keyToTestName(uncheckedKey) === testName) { + // skip snapshots with following keys + // testName n + // testName > xxx n (this is for toMatchSnapshot("xxx") API) + if (/ \d+$| > /.test(uncheckedKey.slice(testName.length))) { this._uncheckedKeys.delete(uncheckedKey) } })