From 54bff58095032c44ab03a1835ca2afed530fb5ee Mon Sep 17 00:00:00 2001 From: Ivan Balukov Date: Fri, 28 Feb 2020 12:09:49 +0300 Subject: [PATCH 1/5] Add types for functions --- types/index.d.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/types/index.d.ts b/types/index.d.ts index ac843417..9f176b2f 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -3,41 +3,41 @@ declare module WebdriverIO { /** * Saves an image of an element */ - saveElement(element: Element, tag: string, saveElementOptions?: {}); + saveElement(element: Element, tag: string, saveElementOptions?: {}): void; /** * Saves an image of a viewport */ - saveScreen(tag: string, saveScreenOptions?: {}); + saveScreen(tag: string, saveScreenOptions?: {}): void; /** * Saves an image of the complete screen */ - saveFullPageScreen(tag: string, saveFullPageScreenOptions?: {}); + saveFullPageScreen(tag: string, saveFullPageScreenOptions?: {}): void; /** * Saves an image of the complete screen with the tabbable lines and dots */ - saveTabbablePage(tag: string, saveTabbableOptions?: {}); + saveTabbablePage(tag: string, saveTabbableOptions?: {}): void; /** * Compare an image of an element */ - checkElement(element: Element, tag: string, checkElementOptions?: {}); + checkElement(element: Element, tag: string, checkElementOptions?: {}): number; /** * Compares an image of a viewport */ - checkScreen(tag: string, checkScreenOptions?: {}); + checkScreen(tag: string, checkScreenOptions?: {}): number; /** * Compares an image of the complete screen */ - checkFullPageScreen(tag: string, checkFullPageOptions?: {}); + checkFullPageScreen(tag: string, checkFullPageOptions?: {}): number; /** * Compares an image of the complete screen with the tabbable lines and dots */ - checkTabbablePage(tag: string, checkTabbableOptions?: {}); + checkTabbablePage(tag: string, checkTabbableOptions?: {}): number; } } From e29c045b0f8cc008676f7e4833823dd3c6dcbbd0 Mon Sep 17 00:00:00 2001 From: Ivan Balukov Date: Fri, 28 Feb 2020 13:12:52 +0300 Subject: [PATCH 2/5] Add full types for saves --- types/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/index.d.ts b/types/index.d.ts index 9f176b2f..d127a605 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -3,22 +3,22 @@ declare module WebdriverIO { /** * Saves an image of an element */ - saveElement(element: Element, tag: string, saveElementOptions?: {}): void; + saveElement(element: Element, tag: string, saveElementOptions?: {}): {fileName: string, path: string, devicePixelRatio: number}; /** * Saves an image of a viewport */ - saveScreen(tag: string, saveScreenOptions?: {}): void; + saveScreen(tag: string, saveScreenOptions?: {}): {fileName: string, path: string, devicePixelRatio: number}; /** * Saves an image of the complete screen */ - saveFullPageScreen(tag: string, saveFullPageScreenOptions?: {}): void; + saveFullPageScreen(tag: string, saveFullPageScreenOptions?: {}): {fileName: string, path: string, devicePixelRatio: number}; /** * Saves an image of the complete screen with the tabbable lines and dots */ - saveTabbablePage(tag: string, saveTabbableOptions?: {}): void; + saveTabbablePage(tag: string, saveTabbableOptions?: {}): {fileName: string, path: string, devicePixelRatio: number}; /** * Compare an image of an element From 9c1d20b4254c57e99190c7234a401cab13c5e035 Mon Sep 17 00:00:00 2001 From: Ivan Balukov Date: Fri, 28 Feb 2020 13:21:37 +0300 Subject: [PATCH 3/5] Add typing for option 'returnAllCompareData: true' --- types/index.d.ts | 91 ++++++++++++++++++++++++++++++------------------ 1 file changed, 57 insertions(+), 34 deletions(-) diff --git a/types/index.d.ts b/types/index.d.ts index d127a605..202d1bf1 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,43 +1,66 @@ declare module WebdriverIO { - interface Browser { - /** - * Saves an image of an element - */ - saveElement(element: Element, tag: string, saveElementOptions?: {}): {fileName: string, path: string, devicePixelRatio: number}; + interface Browser { + /** + * Saves an image of an element + */ + saveElement( + element: Element, + tag: string, + saveElementOptions?: {} + ): { fileName: string; path: string; devicePixelRatio: number }; - /** - * Saves an image of a viewport - */ - saveScreen(tag: string, saveScreenOptions?: {}): {fileName: string, path: string, devicePixelRatio: number}; + /** + * Saves an image of a viewport + */ + saveScreen(tag: string, saveScreenOptions?: {}): { fileName: string; path: string; devicePixelRatio: number }; - /** - * Saves an image of the complete screen - */ - saveFullPageScreen(tag: string, saveFullPageScreenOptions?: {}): {fileName: string, path: string, devicePixelRatio: number}; + /** + * Saves an image of the complete screen + */ + saveFullPageScreen( + tag: string, + saveFullPageScreenOptions?: {} + ): { fileName: string; path: string; devicePixelRatio: number }; - /** - * Saves an image of the complete screen with the tabbable lines and dots - */ - saveTabbablePage(tag: string, saveTabbableOptions?: {}): {fileName: string, path: string, devicePixelRatio: number}; + /** + * Saves an image of the complete screen with the tabbable lines and dots + */ + saveTabbablePage( + tag: string, + saveTabbableOptions?: {} + ): { fileName: string; path: string; devicePixelRatio: number }; - /** - * Compare an image of an element - */ - checkElement(element: Element, tag: string, checkElementOptions?: {}): number; + /** + * Compare an image of an element + */ + checkElement( + element: Element, + tag: string, + checkElementOptions?: {} + ): number | { fileName: string; folders: { actual: string; baseline: string }; misMatchPercentage: number }; - /** - * Compares an image of a viewport - */ - checkScreen(tag: string, checkScreenOptions?: {}): number; + /** + * Compares an image of a viewport + */ + checkScreen( + tag: string, + checkScreenOptions?: {} + ): number | { fileName: string; folders: { actual: string; baseline: string }; misMatchPercentage: number }; - /** - * Compares an image of the complete screen - */ - checkFullPageScreen(tag: string, checkFullPageOptions?: {}): number; + /** + * Compares an image of the complete screen + */ + checkFullPageScreen( + tag: string, + checkFullPageOptions?: {} + ): number | { fileName: string; folders: { actual: string; baseline: string }; misMatchPercentage: number }; - /** - * Compares an image of the complete screen with the tabbable lines and dots - */ - checkTabbablePage(tag: string, checkTabbableOptions?: {}): number; - } + /** + * Compares an image of the complete screen with the tabbable lines and dots + */ + checkTabbablePage( + tag: string, + checkTabbableOptions?: {} + ): number | { fileName: string; folders: { actual: string; baseline: string }; misMatchPercentage: number }; + } } From f295c91a135a0d24d54c12d284c84a1ac6b7cf7a Mon Sep 17 00:00:00 2001 From: Ivan Balukov Date: Fri, 28 Feb 2020 13:28:35 +0300 Subject: [PATCH 4/5] Add 'diff' as an option --- types/index.d.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/types/index.d.ts b/types/index.d.ts index 202d1bf1..cd59794a 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -37,7 +37,9 @@ declare module WebdriverIO { element: Element, tag: string, checkElementOptions?: {} - ): number | { fileName: string; folders: { actual: string; baseline: string }; misMatchPercentage: number }; + ): + | number + | { fileName: string; folders: { actual: string; baseline: string; diff?: string }; misMatchPercentage: number }; /** * Compares an image of a viewport @@ -45,7 +47,9 @@ declare module WebdriverIO { checkScreen( tag: string, checkScreenOptions?: {} - ): number | { fileName: string; folders: { actual: string; baseline: string }; misMatchPercentage: number }; + ): + | number + | { fileName: string; folders: { actual: string; baseline: string; diff?: string }; misMatchPercentage: number }; /** * Compares an image of the complete screen @@ -53,7 +57,9 @@ declare module WebdriverIO { checkFullPageScreen( tag: string, checkFullPageOptions?: {} - ): number | { fileName: string; folders: { actual: string; baseline: string }; misMatchPercentage: number }; + ): + | number + | { fileName: string; folders: { actual: string; baseline: string; diff?: string }; misMatchPercentage: number }; /** * Compares an image of the complete screen with the tabbable lines and dots @@ -61,6 +67,8 @@ declare module WebdriverIO { checkTabbablePage( tag: string, checkTabbableOptions?: {} - ): number | { fileName: string; folders: { actual: string; baseline: string }; misMatchPercentage: number }; + ): + | number + | { fileName: string; folders: { actual: string; baseline: string; diff?: string }; misMatchPercentage: number }; } } From 8530acd5038fe4dc8d4c366b2c2ba048db35afce Mon Sep 17 00:00:00 2001 From: Ivan Balukov Date: Wed, 4 Mar 2020 13:59:02 +0300 Subject: [PATCH 5/5] Revert types to any --- types/index.d.ts | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/types/index.d.ts b/types/index.d.ts index cd59794a..bbdd3157 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -33,42 +33,21 @@ declare module WebdriverIO { /** * Compare an image of an element */ - checkElement( - element: Element, - tag: string, - checkElementOptions?: {} - ): - | number - | { fileName: string; folders: { actual: string; baseline: string; diff?: string }; misMatchPercentage: number }; + checkElement(element: Element, tag: string, checkElementOptions?: {}): any; /** * Compares an image of a viewport */ - checkScreen( - tag: string, - checkScreenOptions?: {} - ): - | number - | { fileName: string; folders: { actual: string; baseline: string; diff?: string }; misMatchPercentage: number }; + checkScreen(tag: string, checkScreenOptions?: {}): any; /** * Compares an image of the complete screen */ - checkFullPageScreen( - tag: string, - checkFullPageOptions?: {} - ): - | number - | { fileName: string; folders: { actual: string; baseline: string; diff?: string }; misMatchPercentage: number }; + checkFullPageScreen(tag: string, checkFullPageOptions?: {}): any; /** * Compares an image of the complete screen with the tabbable lines and dots */ - checkTabbablePage( - tag: string, - checkTabbableOptions?: {} - ): - | number - | { fileName: string; folders: { actual: string; baseline: string; diff?: string }; misMatchPercentage: number }; + checkTabbablePage(tag: string, checkTabbableOptions?: {}): any; } }