@@ -92,6 +92,25 @@ class ResembleHelper extends Helper {
92
92
else throw new Error ( "Method only works with Puppeteer" ) ;
93
93
}
94
94
95
+ /**
96
+ * This method attaches image attachments of the base, screenshot and diff to the allure reporter when the mismatch exceeds tolerance.
97
+ * @param baseImage
98
+ * @param misMatch
99
+ * @param tolerance
100
+ * @returns {Promise<void> }
101
+ */
102
+
103
+ async _addAttachment ( baseImage , misMatch , tolerance ) {
104
+ const allure = codeceptjs . container . plugins ( 'allure' ) ;
105
+ const diffImage = "Diff_" + baseImage . split ( "." ) [ 0 ] + ".png" ;
106
+
107
+ if ( allure !== undefined && misMatch >= tolerance ) {
108
+ allure . addAttachment ( 'Base Image' , fs . readFileSync ( this . config . baseFolder + baseImage ) , 'image/png' ) ;
109
+ allure . addAttachment ( 'Screenshot Image' , fs . readFileSync ( this . config . screenshotFolder + baseImage ) , 'image/png' ) ;
110
+ allure . addAttachment ( 'Diff Image' , fs . readFileSync ( this . config . diffFolder + diffImage ) , 'image/png' ) ;
111
+ }
112
+ }
113
+
95
114
/**
96
115
* This method uploads the diff and screenshot images into the bucket with diff image under bucketName/diff/diffImage and the screenshot image as
97
116
* bucketName/output/ssImage
@@ -216,6 +235,8 @@ class ResembleHelper extends Helper {
216
235
217
236
const misMatch = await this . _fetchMisMatchPercentage ( baseImage , options ) ;
218
237
238
+ this . _addAttachment ( baseImage , misMatch , options . tolerance ) ;
239
+
219
240
if ( awsC !== undefined ) {
220
241
let ifUpload = options . prepareBaseImage === false ? false : true ;
221
242
await this . _upload ( awsC . accessKeyId , awsC . secretAccessKey , awsC . region , awsC . bucketName , baseImage , ifUpload )
@@ -253,6 +274,8 @@ class ResembleHelper extends Helper {
253
274
options . boundingBox = await this . _getBoundingBox ( selector ) ;
254
275
const misMatch = await this . _fetchMisMatchPercentage ( baseImage , options ) ;
255
276
277
+ this . _addAttachment ( baseImage , misMatch , options . tolerance ) ;
278
+
256
279
if ( awsC !== undefined ) {
257
280
let ifUpload = options . prepareBaseImage === false ? false : true ;
258
281
await this . _upload ( awsC . accessKeyId , awsC . secretAccessKey , awsC . region , awsC . bucketName , baseImage , ifUpload )
0 commit comments