Skip to content

Commit 26d4601

Browse files
committed
* Fixed "this.resolveImagePathRelativeFromReport is not a function" caused by fix of codeceptjs#95
* Fixed UnhandledPromiseRejectionWarning (missing awaits) * Updated TS definition using `npx -p typescript tsc index.js --declaration --allowJs --emitDeclarationOnly`
1 parent 52afc96 commit 26d4601

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

index.d.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ declare class ResembleHelper {
1010
screenshotFolder: string;
1111
prepareBaseImage: any;
1212
resolvePath(folderPath: any): any;
13+
_resolveRelativePath(folderPath: any): any;
1314
/**
1415
* Compare Images
1516
*
1617
* @param image
1718
* @param options
1819
* @returns {Promise<resolve | reject>}
1920
*/
20-
_compareImages(image: any, options: any): Promise<any | any>;
21+
_compareImages(image: any, options: any): Promise<resolve | reject>;
2122
/**
2223
*
2324
* @param image

index.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class ResembleHelper extends Helper {
4141
absolutePathOfReportFolder = Container.mocha().options.reporterOptions.reportDir;
4242
}
4343
// support mocha-multi-reporters
44-
if (Container.mocha() && typeof Container.mocha().options.reporterOptions.mochawesomeReporterOptions.reportDir !== 'undefined') {
44+
if (Container.mocha() && typeof Container.mocha().options.reporterOptions.mochawesomeReporterOptions?.reportDir !== 'undefined') {
4545
absolutePathOfReportFolder = Container.mocha().options.reporterOptions.mochawesomeReporterOptions.reportDir;
4646
}
4747
return path.relative(absolutePathOfReportFolder, absolutePathOfImage);
@@ -191,11 +191,11 @@ class ResembleHelper extends Helper {
191191

192192
if (mocha !== undefined && misMatch >= options.tolerance) {
193193
await mocha.addMochawesomeContext("Base Image");
194-
await mocha.addMochawesomeContext(this.resolveImagePathRelativeFromReport(this._getBaseImagePath(baseImage, options)));
194+
await mocha.addMochawesomeContext(this._resolveRelativePath(this._getBaseImagePath(baseImage, options)));
195195
await mocha.addMochawesomeContext("ScreenShot Image");
196-
await mocha.addMochawesomeContext(this.resolveImagePathRelativeFromReport(this._getActualImagePath(baseImage)));
196+
await mocha.addMochawesomeContext(this._resolveRelativePath(this._getActualImagePath(baseImage)));
197197
await mocha.addMochawesomeContext("Diff Image");
198-
await mocha.addMochawesomeContext(this.resolveImagePathRelativeFromReport(this._getDiffImagePath(baseImage)));
198+
await mocha.addMochawesomeContext(this._resolveRelativePath(this._getDiffImagePath(baseImage)));
199199
}
200200
}
201201

@@ -344,8 +344,8 @@ class ResembleHelper extends Helper {
344344
options.boundingBox = await this._getBoundingBox(selector);
345345
}
346346
const misMatch = await this._fetchMisMatchPercentage(baseImage, options);
347-
this._addAttachment(baseImage, misMatch, options);
348-
this._addMochaContext(baseImage, misMatch, options);
347+
await this._addAttachment(baseImage, misMatch, options);
348+
await this._addMochaContext(baseImage, misMatch, options);
349349
if (awsC !== undefined) {
350350
await this._upload(awsC.accessKeyId, awsC.secretAccessKey, awsC.region, awsC.bucketName, baseImage, options)
351351
}

0 commit comments

Comments
 (0)