Skip to content

PMM-5039 Adding Mochawesome reporter Support #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>}
*/

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
Expand Down Expand Up @@ -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)
}
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand Down