@wdio/image-comparison-core
Version:
Image comparison core module for @wdio/visual-service - WebdriverIO visual testing framework
134 lines • 6.55 kB
TypeScript
import type { BaseExecuteCompareOptions, BuildBaseExecuteCompareOptionsOptions, BuildFolderOptionsOptions, CommonCheckVariables, ComparisonFilePaths, ExecuteNativeClickOptions, ExtractCommonCheckVariablesOptions, FolderOptions, FormatFileNameOptions, GetAddressBarShadowPaddingOptions, GetAndCreatePathOptions, GetIosBezelImageNames, GetMobileScreenSizeOptions, GetMobileViewPortPositionOptions, GetToolBarShadowPaddingOptions, LoadBase64HtmlOptions, PrepareComparisonFilePathsOptions, ScreenshotSize } from './utils.interfaces.js';
import type { ClassOptions, CompareOptions } from './options.interfaces.js';
import type { DeviceRectangles } from '../methods/rectangles.interfaces.js';
import type { BaseDimensions } from '../base.interfaces.js';
/**
* Get and create a folder
*/
export declare function getAndCreatePath(folder: string, options: GetAndCreatePathOptions): string;
/**
* Format the filename
*/
export declare function formatFileName(options: FormatFileNameOptions): string;
/**
* Checks if the test is executed in a browser
* checking for app is not sufficient because different vendors have different
* custom names and or solutions for the app
*/
export declare function checkTestInBrowser(browserName: string): boolean;
/**
* Checks if the test is executed in a browser on a mobile phone
*/
export declare function checkTestInMobileBrowser(isMobile: boolean, browserName: string): boolean;
/**
* Checks if this is a native webscreenshot on android
*/
export declare function checkAndroidNativeWebScreenshot(isAndroid: boolean, nativeWebscreenshot: boolean): boolean;
/**
* Checks if this is an Android chromedriver screenshot
*/
export declare function checkAndroidChromeDriverScreenshot(isAndroid: boolean, nativeWebScreenshot: boolean): boolean;
/**
* Get the address bar shadow padding. This is only needed for Android native webscreenshot and iOS
*/
export declare function getAddressBarShadowPadding(options: GetAddressBarShadowPaddingOptions): number;
/**
* Get the tool bar shadow padding. Add some extra padding for iOS when we have a home bar
*/
export declare function getToolBarShadowPadding(options: GetToolBarShadowPaddingOptions): number;
/**
* Calculate the data based on the device pixel ratio
*/
export declare function calculateDprData<T>(data: T, devicePixelRatio: number): T;
/**
* Wait for an amount of milliseconds
*/
export declare function waitFor(milliseconds: number): Promise<void>;
/**
* Get the size of a screenshot in pixels without the device pixel ratio
*/
export declare function getBase64ScreenshotSize(screenshot: string, devicePixelRation?: number): ScreenshotSize;
/**
* Get the device pixel ratio
*/
export declare function getDevicePixelRatio(screenshot: string, deviceScreenSize: BaseDimensions): number;
/**
* Get the iOS bezel image names
*/
export declare function getIosBezelImageNames(normalizedDeviceName: string): GetIosBezelImageNames;
/**
* Validate that the item is an object
*/
export declare function isObject(item: unknown): item is object | Function;
/**
* Validate if it's storybook
*/
export declare function isStorybook(): boolean;
/**
* Check if we want to update baseline images
*/
export declare function updateVisualBaseline(): boolean;
/**
* Log the deprecated root compareOptions (at `ClassOptions` level)
* and returns non-undefined ones to be added back to the config
*/
export declare function logAllDeprecatedCompareOptions(options: ClassOptions): Partial<CompareOptions>;
/**
* Get the mobile screen size, this is different for native and webview
*/
export declare function getMobileScreenSize({ browserInstance, isIOS, isNativeContext, }: GetMobileScreenSizeOptions): Promise<BaseDimensions>;
/**
* Load a base64 HTML page in the browser
*/
export declare function loadBase64Html({ browserInstance, isIOS }: LoadBase64HtmlOptions): Promise<void>;
/**
* Execute a native click
*/
export declare function executeNativeClick({ browserInstance, isIOS, x, y }: ExecuteNativeClickOptions): Promise<void>;
/**
* Get the mobile viewport position, we determine this by:
* 1. Loading a base64 HTML page
* 2. Injecting an overlay on top of the webview with an event listener that stores the click position in the webview
* 3. Clicking on the overlay in the center of the screen with a native click
* 4. Getting the data from the overlay and removing it
* 5. Calculating the position of the viewport based on the click position of the native click vs the overlay
* 6. Returning the calculated values
*/
export declare function getMobileViewPortPosition({ browserInstance, initialDeviceRectangles, isAndroid, isIOS, isNativeContext, nativeWebScreenshot, screenHeight, screenWidth, }: GetMobileViewPortPositionOptions): Promise<DeviceRectangles>;
/**
* Get the value of a method or the default value
*/
export declare function getMethodOrWicOption<T, K extends keyof T>(method: Partial<T> | undefined, wic: T, key: K): T[K];
/**
* Determine if the Bidi screenshot can be used
*/
export declare function canUseBidiScreenshot(browserInstance: WebdriverIO.Browser): boolean;
/**
* Helper function to safely check boolean properties with proper defaults
*/
export declare function getBooleanOption(options: ClassOptions, key: keyof ClassOptions, defaultValue: boolean): boolean;
/**
* Helper function to create conditional property objects for cleaner spread operations
*/
export declare function createConditionalProperty<T>(condition: boolean, key: string, value: T): Record<string, T> | {};
/**
* Check if resizeDimensions has any non-zero values (indicating it's been changed from default)
*/
export declare function hasResizeDimensions(resizeDimensions: any): boolean;
/**
* Extracts common variables used across all check methods to reduce duplication
*/
export declare function extractCommonCheckVariables(options: ExtractCommonCheckVariablesOptions): CommonCheckVariables;
/**
* Builds folder options object used across all check methods to reduce duplication
*/
export declare function buildFolderOptions(options: BuildFolderOptionsOptions): FolderOptions;
/**
* Builds base execute compare options object used across all check methods to reduce duplication
*/
export declare function buildBaseExecuteCompareOptions(options: BuildBaseExecuteCompareOptionsOptions): BaseExecuteCompareOptions;
/**
* Prepare all file paths needed for image comparison
*/
export declare function prepareComparisonFilePaths(options: PrepareComparisonFilePathsOptions): ComparisonFilePaths;
//# sourceMappingURL=utils.d.ts.map