Skip to content

Commit

Permalink
Cut out outputDir from expectations paths
Browse files Browse the repository at this point in the history
  • Loading branch information
yury-s committed Apr 4, 2024
1 parent 04afd99 commit e71c892
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
26 changes: 13 additions & 13 deletions tests/playwright-test/golden.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,49 +113,49 @@ test('should generate separate actual results for repeating names', async ({ run
const outputText = result.output;
const attachments = outputText.split('\n').filter(l => l.startsWith('## ')).map(l => l.substring(3)).map(l => JSON.parse(l))[0];
for (const attachment of attachments) {
attachment.path = attachment.path.replace(/\\/g, '/').replace(/.*test-results\//, '');
attachment.path = attachment.path.replace(testInfo.outputDir, '').substring(1).replace(/\\/g, '/');
attachment.name = attachment.name.replace(/\\/g, '/');
}
expect(attachments).toEqual([
{
'name': 'foo-expected.txt',
'contentType': 'text/plain',
'path': 'golden-should-generate-separate-actual-results-for-repeating-names-playwright-test/a.spec.js-snapshots/foo.txt'
'path': 'a.spec.js-snapshots/foo.txt'
},
{
'name': 'foo-actual.txt',
'contentType': 'text/plain',
'path': 'a-is-a-test/foo-actual.txt'
'path': 'test-results/a-is-a-test/foo-actual.txt'
},
{
'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'
'path': 'a.spec.js-snapshots/foo.txt'
},
{
'name': 'foo-1-actual.txt',
'contentType': 'text/plain',
'path': 'a-is-a-test/foo-1-actual.txt'
'path': 'test-results/a-is-a-test/foo-1-actual.txt'
},
{
'name': 'bar/baz-expected.txt',
'contentType': 'text/plain',
'path': 'golden-should-generate-separate-actual-results-for-repeating-names-playwright-test/a.spec.js-snapshots/bar/baz.txt'
'path': 'a.spec.js-snapshots/bar/baz.txt'
},
{
'name': 'bar/baz-actual.txt',
'contentType': 'text/plain',
'path': 'a-is-a-test/bar-baz-actual.txt'
'path': 'test-results/a-is-a-test/bar-baz-actual.txt'
},
{
'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'
'path': 'a.spec.js-snapshots/bar/baz.txt'
},
{
'name': 'bar/baz-1-actual.txt',
'contentType': 'text/plain',
'path': 'a-is-a-test/bar-baz-1-actual.txt'
'path': 'test-results/a-is-a-test/bar-baz-1-actual.txt'
}
]);
});
Expand Down Expand Up @@ -1047,22 +1047,22 @@ test('should attach expected/actual/diff for different sizes', async ({ runInlin
expect(outputText).toContain('4 pixels (ratio 1.00 of all image pixels) are different.');
const attachments = outputText.split('\n').filter(l => l.startsWith('## ')).map(l => l.substring(3)).map(l => JSON.parse(l))[0];
for (const attachment of attachments)
attachment.path = attachment.path.replace(/\\/g, '/').replace(/.*test-results\//, '');
attachment.path = attachment.path.replace(testInfo.outputDir, '').substring(1).replace(/\\/g, '/');
expect(attachments).toEqual([
{
name: 'snapshot-expected.png',
contentType: 'image/png',
path: 'golden-should-attach-expected-actual-diff-for-different-sizes-playwright-test/a.spec.js-snapshots/snapshot.png'
path: 'a.spec.js-snapshots/snapshot.png'
},
{
name: 'snapshot-actual.png',
contentType: 'image/png',
path: 'a-is-a-test/snapshot-actual.png'
path: 'test-results/a-is-a-test/snapshot-actual.png'
},
{
name: 'snapshot-diff.png',
contentType: 'image/png',
path: 'a-is-a-test/snapshot-diff.png'
path: 'test-results/a-is-a-test/snapshot-diff.png'
},
]);
});
Expand Down
8 changes: 4 additions & 4 deletions tests/playwright-test/to-have-screenshot.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1086,22 +1086,22 @@ test('should attach expected/actual/diff when sizes are different', async ({ run
expect(outputText).toContain('4 pixels (ratio 0.01 of all image pixels) are different.');
const attachments = outputText.split('\n').filter(l => l.startsWith('## ')).map(l => l.substring(3)).map(l => JSON.parse(l))[0];
for (const attachment of attachments)
attachment.path = attachment.path.replace(/\\/g, '/').replace(/.*test-results\//, '');
attachment.path = attachment.path.replace(testInfo.outputDir, '').substring(1).replace(/\\/g, '/');
expect(attachments).toEqual([
{
name: 'snapshot-expected.png',
contentType: 'image/png',
path: 'to-have-screenshot-should-attach-expected-actual-diff-when-sizes-are-different-playwright-test/__screenshots__/a.spec.js/snapshot.png',
path: '__screenshots__/a.spec.js/snapshot.png',
},
{
name: 'snapshot-actual.png',
contentType: 'image/png',
path: 'a-is-a-test/snapshot-actual.png'
path: 'test-results/a-is-a-test/snapshot-actual.png'
},
{
name: 'snapshot-diff.png',
contentType: 'image/png',
path: 'a-is-a-test/snapshot-diff.png'
path: 'test-results/a-is-a-test/snapshot-diff.png'
},
]);
});
Expand Down

0 comments on commit e71c892

Please sign in to comment.