@@ -147,6 +147,28 @@ class ResembleHelper extends Helper {
147147 }
148148 }
149149
150+ /**
151+ * This method attaches context, and images to Mochawesome reporter when the mismatch exceeds tolerance.
152+ * @param baseImage
153+ * @param misMatch
154+ * @param tolerance
155+ * @returns {Promise<void> }
156+ */
157+
158+ async _addMochaContext ( baseImage , misMatch , tolerance ) {
159+ const mocha = this . helpers [ 'Mochawesome' ] ;
160+ const diffImage = "Diff_" + baseImage . split ( "." ) [ 0 ] + ".png" ;
161+
162+ if ( mocha !== undefined && misMatch >= tolerance ) {
163+ await mocha . addMochawesomeContext ( "Base Image" ) ;
164+ await mocha . addMochawesomeContext ( this . baseFolder + baseImage ) ;
165+ await mocha . addMochawesomeContext ( "ScreenShot Image" ) ;
166+ await mocha . addMochawesomeContext ( this . screenshotFolder + baseImage ) ;
167+ await mocha . addMochawesomeContext ( "Diff Image" ) ;
168+ await mocha . addMochawesomeContext ( this . diffFolder + diffImage ) ;
169+ }
170+ }
171+
150172 /**
151173 * This method uploads the diff and screenshot images into the bucket with diff image under bucketName/diff/diffImage and the screenshot image as
152174 * bucketName/output/ssImage
@@ -292,6 +314,8 @@ class ResembleHelper extends Helper {
292314
293315 this . _addAttachment ( baseImage , misMatch , options . tolerance ) ;
294316
317+ this . _addMochaContext ( baseImage , misMatch , options . tolerance ) ;
318+
295319 if ( awsC !== undefined ) {
296320 await this . _upload ( awsC . accessKeyId , awsC . secretAccessKey , awsC . region , awsC . bucketName , baseImage , options . prepareBaseImage )
297321 }
0 commit comments