Skip to content

Commit 3f1bb95

Browse files
committed
fix: fix tests
1 parent 25ef013 commit 3f1bb95

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

__test__/visual_test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ Before(() => {
77

88
Scenario('seeVisualDiff', () => {
99
I.saveScreenshot('Playwright_doc.png');
10-
I.seeVisualDiff('Playwright_doc.png', {prepareBaseImage: false, tolerance: 0})
10+
I.seeVisualDiff('Playwright_doc.png', {prepareBaseImage: false, tolerance: 20})
1111
});
1212

1313
Scenario('seeVisualDiffForElement', () => {
1414
I.saveElementScreenshot('h2#playwright','element.png');
15-
I.seeVisualDiffForElement('h2#playwright','element.png', {prepareBaseImage: false, tolerance: 0})
15+
I.seeVisualDiffForElement('h2#playwright','element.png', {prepareBaseImage: false, tolerance: 20})
1616
});

src/index.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ interface Config {
2323
prepareBaseImage: string;
2424
}
2525

26+
interface Options {
27+
tolerance?: any;
28+
ignoredBox?: any;
29+
boundingBox?: any;
30+
needsSameDimension?: boolean;
31+
outputSettings?: any;
32+
prepareBaseImage?: boolean;
33+
compareWithImage?: any
34+
}
35+
2636
interface Endpoint {
2737
/**
2838
* The host portion of the endpoint including the port, e.g., example.com:80.
@@ -97,7 +107,7 @@ class ResembleHelper extends Helper {
97107
* @param options
98108
* @returns {Promise<resolve | reject>}
99109
*/
100-
async _compareImages(image: any, options: any) {
110+
async _compareImages(image: any, options: Options) {
101111
const baseImage = this._getBaseImagePath(image, options);
102112
const actualImage = this._getActualImagePath(image);
103113
const diffImage = this._getDiffImagePath(image);
@@ -170,7 +180,7 @@ class ResembleHelper extends Helper {
170180
* @param options
171181
* @returns {Promise<*>}
172182
*/
173-
async _fetchMisMatchPercentage(image: any, options: any) {
183+
async _fetchMisMatchPercentage(image: any, options: Options) {
174184
const result = this._compareImages(image, options);
175185
const data: any = await Promise.resolve(result);
176186
return data.misMatchPercentage;
@@ -219,7 +229,7 @@ class ResembleHelper extends Helper {
219229
* @returns {Promise<void>}
220230
*/
221231

222-
async _addAttachment(baseImage: any, misMatch: any, options: any) {
232+
async _addAttachment(baseImage: any, misMatch: any, options: Options) {
223233
const allure: any = require('codeceptjs').container.plugins("allure");
224234

225235
if (allure !== undefined && misMatch >= options.tolerance) {
@@ -381,7 +391,7 @@ class ResembleHelper extends Helper {
381391
* @param {any} [options] Options ex {prepareBaseImage: true, tolerance: 5} along with Resemble JS Options, read more here: https://github.com/rsmbl/Resemble.js
382392
* @returns {Promise<void>}
383393
*/
384-
async seeVisualDiff(baseImage: any, options: any) {
394+
async seeVisualDiff(baseImage: any, options: Options) {
385395
await this._assertVisualDiff(undefined, baseImage, options);
386396
}
387397

@@ -393,7 +403,7 @@ class ResembleHelper extends Helper {
393403
* @param {any} [options] Options ex {prepareBaseImage: true, tolerance: 5} along with Resemble JS Options, read more here: https://github.com/rsmbl/Resemble.js
394404
* @returns {Promise<void>}
395405
*/
396-
async seeVisualDiffForElement(selector: any, baseImage: any, options: any) {
406+
async seeVisualDiffForElement(selector: any, baseImage: any, options: Options) {
397407
await this._assertVisualDiff(selector, baseImage, options);
398408
}
399409

@@ -581,7 +591,7 @@ class ResembleHelper extends Helper {
581591
* @param options Helper options
582592
* @returns {string}
583593
*/
584-
_getBaseImageName(image: any, options: { compareWithImage: any }) {
594+
_getBaseImageName(image: any, options: { compareWithImage?: any }) {
585595
return options.compareWithImage ? options.compareWithImage : image;
586596
}
587597

@@ -591,7 +601,7 @@ class ResembleHelper extends Helper {
591601
* @param options Helper options
592602
* @returns {string}
593603
*/
594-
_getBaseImagePath(image: string, options: any) {
604+
_getBaseImagePath(image: string, options: Options) {
595605
return this.baseFolder + this._getBaseImageName(image, options);
596606
}
597607

@@ -619,7 +629,7 @@ class ResembleHelper extends Helper {
619629
* @param options Helper options
620630
* @returns {boolean}
621631
*/
622-
_getPrepareBaseImage(options: any) {
632+
_getPrepareBaseImage(options: Options) {
623633
if ("undefined" !== typeof options.prepareBaseImage) {
624634
// Cast to bool with `!!` for backwards compatibility
625635
return !!options.prepareBaseImage;

0 commit comments

Comments
 (0)