Skip to content

Commit 91e23fe

Browse files
authored
Merge pull request #54 from puneet0191/master
PMM-5039 Adding Mochaweomse reporter Support
2 parents 70bfa39 + 6a7eca8 commit 91e23fe

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

index.js

+24
Original file line numberDiff line numberDiff line change
@@ -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
}

package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codeceptjs-resemblehelper",
3-
"version": "1.8.0",
3+
"version": "1.9.0",
44
"description": "Resemble Js helper for CodeceptJS, with Support for Webdriver, Puppeteer & Appium",
55
"repository": {
66
"type": "git",
@@ -18,7 +18,9 @@
1818
},
1919
"devDependencies": {
2020
"allure-commandline": "^2.13.0",
21-
"codeceptjs": "^2.3.5"
21+
"codeceptjs": "^2.3.5",
22+
"mocha": "^6.2.2",
23+
"mochawesome": "^4.1.0"
2224
},
2325
"keywords": [
2426
"codeceptJS",

0 commit comments

Comments
 (0)