diff --git a/index.js b/index.js index 3fa0c5e..ecb5383 100644 --- a/index.js +++ b/index.js @@ -147,6 +147,28 @@ class ResembleHelper extends Helper { } } + /** + * This method attaches context, and images to Mochawesome reporter when the mismatch exceeds tolerance. + * @param baseImage + * @param misMatch + * @param tolerance + * @returns {Promise} + */ + + async _addMochaContext(baseImage, misMatch, tolerance) { + const mocha = this.helpers['Mochawesome']; + const diffImage = "Diff_" + baseImage.split(".")[0] + ".png"; + + if (mocha !== undefined && misMatch >= tolerance) { + await mocha.addMochawesomeContext("Base Image"); + await mocha.addMochawesomeContext(this.baseFolder + baseImage); + await mocha.addMochawesomeContext("ScreenShot Image"); + await mocha.addMochawesomeContext(this.screenshotFolder + baseImage); + await mocha.addMochawesomeContext("Diff Image"); + await mocha.addMochawesomeContext(this.diffFolder + diffImage); + } + } + /** * This method uploads the diff and screenshot images into the bucket with diff image under bucketName/diff/diffImage and the screenshot image as * bucketName/output/ssImage @@ -292,6 +314,8 @@ class ResembleHelper extends Helper { this._addAttachment(baseImage, misMatch, options.tolerance); + this._addMochaContext(baseImage, misMatch, options.tolerance); + if (awsC !== undefined) { await this._upload(awsC.accessKeyId, awsC.secretAccessKey, awsC.region, awsC.bucketName, baseImage, options.prepareBaseImage) } diff --git a/package.json b/package.json index 37e055b..d203268 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codeceptjs-resemblehelper", - "version": "1.8.0", + "version": "1.9.0", "description": "Resemble Js helper for CodeceptJS, with Support for Webdriver, Puppeteer & Appium", "repository": { "type": "git", @@ -18,7 +18,9 @@ }, "devDependencies": { "allure-commandline": "^2.13.0", - "codeceptjs": "^2.3.5" + "codeceptjs": "^2.3.5", + "mocha": "^6.2.2", + "mochawesome": "^4.1.0" }, "keywords": [ "codeceptJS",