1
1
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
// SPDX-License-Identifier: Apache-2.0
3
3
import { test , expect , describe } from 'vitest' ;
4
+ import * as allure from 'allure-js-commons' ;
4
5
import fs from 'fs' ;
5
6
import { PNG } from 'pngjs' ;
6
7
import useBrowser from '../src/use-browser' ;
@@ -33,7 +34,13 @@ describe('compare images', () => {
33
34
const firstResult = await page . captureBySelector ( '#box1' ) ;
34
35
await browser . refresh ( ) ;
35
36
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 ( {
37
44
firstImage : expect . any ( Buffer ) ,
38
45
secondImage : expect . any ( Buffer ) ,
39
46
diffImage : null ,
@@ -46,7 +53,6 @@ describe('compare images', () => {
46
53
test (
47
54
'should compare viewport screenshots' ,
48
55
setupTest ( async ( page , browser ) => {
49
-
50
56
const firstResult = await page . captureViewport ( ) ;
51
57
await browser . refresh ( ) ;
52
58
0 commit comments