@@ -92,6 +92,25 @@ class ResembleHelper extends Helper {
9292 else throw new Error ( "Method only works with Puppeteer" ) ;
9393 }
9494
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+
95114 /**
96115 * This method uploads the diff and screenshot images into the bucket with diff image under bucketName/diff/diffImage and the screenshot image as
97116 * bucketName/output/ssImage
@@ -216,6 +235,8 @@ class ResembleHelper extends Helper {
216235
217236 const misMatch = await this . _fetchMisMatchPercentage ( baseImage , options ) ;
218237
238+ this . _addAttachment ( baseImage , misMatch , options . tolerance ) ;
239+
219240 if ( awsC !== undefined ) {
220241 let ifUpload = options . prepareBaseImage === false ? false : true ;
221242 await this . _upload ( awsC . accessKeyId , awsC . secretAccessKey , awsC . region , awsC . bucketName , baseImage , ifUpload )
@@ -253,6 +274,8 @@ class ResembleHelper extends Helper {
253274 options . boundingBox = await this . _getBoundingBox ( selector ) ;
254275 const misMatch = await this . _fetchMisMatchPercentage ( baseImage , options ) ;
255276
277+ this . _addAttachment ( baseImage , misMatch , options . tolerance ) ;
278+
256279 if ( awsC !== undefined ) {
257280 let ifUpload = options . prepareBaseImage === false ? false : true ;
258281 await this . _upload ( awsC . accessKeyId , awsC . secretAccessKey , awsC . region , awsC . bucketName , baseImage , ifUpload )
0 commit comments