Skip to content

Commit 10e9ee3

Browse files
committed
dump images
1 parent 5c1afa2 commit 10e9ee3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

test/compare-images.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33
import { test, expect, describe } from 'vitest';
4+
import * as allure from 'allure-js-commons';
45
import fs from 'fs';
56
import { PNG } from 'pngjs';
67
import useBrowser from '../src/use-browser';
@@ -33,7 +34,13 @@ describe('compare images', () => {
3334
const firstResult = await page.captureBySelector('#box1');
3435
await browser.refresh();
3536
const secondResult = await page.captureBySelector('#box1');
36-
await expect(cropAndCompare(firstResult, secondResult)).resolves.toEqual({
37+
const compareResult = await cropAndCompare(firstResult, secondResult);
38+
await allure.attachment('first', compareResult.firstImage, { contentType: allure.ContentType.PNG });
39+
await allure.attachment('second', compareResult.secondImage, { contentType: allure.ContentType.PNG });
40+
if (compareResult.diffImage) {
41+
await allure.attachment('diff', compareResult.diffImage, { contentType: allure.ContentType.PNG });
42+
}
43+
expect(compareResult).toEqual({
3744
firstImage: expect.any(Buffer),
3845
secondImage: expect.any(Buffer),
3946
diffImage: null,
@@ -46,7 +53,6 @@ describe('compare images', () => {
4653
test(
4754
'should compare viewport screenshots',
4855
setupTest(async (page, browser) => {
49-
5056
const firstResult = await page.captureViewport();
5157
await browser.refresh();
5258

0 commit comments

Comments
 (0)