From 56afacb1e295a4b6c223d59b94f4439067f7d332 Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Tue, 12 Mar 2024 09:26:34 -0700 Subject: [PATCH] Add index suffix before extension --- packages/playwright/src/matchers/toMatchSnapshot.ts | 2 +- tests/playwright-test/golden.spec.ts | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/playwright/src/matchers/toMatchSnapshot.ts b/packages/playwright/src/matchers/toMatchSnapshot.ts index 317a0144d9..4e12d18fe6 100644 --- a/packages/playwright/src/matchers/toMatchSnapshot.ts +++ b/packages/playwright/src/matchers/toMatchSnapshot.ts @@ -140,7 +140,7 @@ class SnapshotHelper { snapshotNames.namedSnapshotIndex[joinedName] = (snapshotNames.namedSnapshotIndex[joinedName] || 0) + 1; const index = snapshotNames.namedSnapshotIndex[joinedName]; if (index > 1) - this.snapshotName = `${joinedName}-${index - 1}`; + this.snapshotName = addSuffixToFilePath(joinedName, `-${index - 1}`); else this.snapshotName = joinedName; } diff --git a/tests/playwright-test/golden.spec.ts b/tests/playwright-test/golden.spec.ts index 3c050de8e4..e768e1cf60 100644 --- a/tests/playwright-test/golden.spec.ts +++ b/tests/playwright-test/golden.spec.ts @@ -128,14 +128,14 @@ test('should generate separate actual results for repeating names', async ({ run 'path': 'a-is-a-test/foo-actual.txt' }, { - 'name': 'foo-expected.txt-1', + 'name': 'foo-1-expected.txt', 'contentType': 'text/plain', 'path': 'golden-should-generate-separate-actual-results-for-repeating-names-playwright-test/a.spec.js-snapshots/foo.txt' }, { - 'name': 'foo-actual.txt-1', + 'name': 'foo-1-actual.txt', 'contentType': 'text/plain', - 'path': 'a-is-a-test/foo-actual.txt-1' + 'path': 'a-is-a-test/foo-1-actual.txt' }, { 'name': 'bar/baz-expected.txt', @@ -148,14 +148,14 @@ test('should generate separate actual results for repeating names', async ({ run 'path': 'a-is-a-test/bar-baz-actual.txt' }, { - 'name': 'bar/baz-expected.txt-1', + 'name': 'bar/baz-1-expected.txt', 'contentType': 'text/plain', 'path': 'golden-should-generate-separate-actual-results-for-repeating-names-playwright-test/a.spec.js-snapshots/bar/baz.txt' }, { - 'name': 'bar/baz-actual.txt-1', + 'name': 'bar/baz-1-actual.txt', 'contentType': 'text/plain', - 'path': 'a-is-a-test/bar-baz-actual.txt-1' + 'path': 'a-is-a-test/bar-baz-1-actual.txt' } ]); });