11// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22// SPDX-License-Identifier: Apache-2.0
33import { test , expect , describe } from 'vitest' ;
4+ import * as allure from 'allure-js-commons' ;
45import fs from 'fs' ;
56import { PNG } from 'pngjs' ;
67import 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