@augment-vir/test
Version:
A universal testing suite that works with Mocha style test runners _and_ Node.js's built-in test runner.
88 lines (87 loc) • 3.14 kB
TypeScript
import { type PartialWithUndefined } from '@augment-vir/common';
import { type Locator } from '@playwright/test';
import { type UniversalTestContext } from '../augments/universal-testing-suite/universal-test-context.js';
/** This is used for type extraction because Playwright does not export the types we need. */
declare function extractScreenshotMethod(): {
(name: string | ReadonlyArray<string>, options?: {
animations?: "disabled" | "allow";
caret?: "hide" | "initial";
mask?: Array<Locator>;
maskColor?: string;
maxDiffPixelRatio?: number;
maxDiffPixels?: number;
omitBackground?: boolean;
scale?: "css" | "device";
stylePath?: string | Array<string>;
threshold?: number;
timeout?: number;
}): Promise<void>;
(options?: {
animations?: "disabled" | "allow";
caret?: "hide" | "initial";
mask?: Array<Locator>;
maskColor?: string;
maxDiffPixelRatio?: number;
maxDiffPixels?: number;
omitBackground?: boolean;
scale?: "css" | "device";
stylePath?: string | Array<string>;
threshold?: number;
timeout?: number;
}): Promise<void>;
};
/**
* Correct options for `locator.screenshot`. (Playwright's `LocatorScreenshotOptions` export is
* wrong.)
*
* @category Internal
* @default defaultScreenshotOptions
*/
export type LocatorScreenshotOptions = NonNullable<Parameters<ReturnType<typeof extractScreenshotMethod>>[0]>;
/**
* Default internal options for {@link LocatorScreenshotOptions}, used in {@link expectScreenshot}
*
* @category Internal
*/
export declare const defaultScreenshotOptions: {
animations: "disabled";
caret: "hide";
timeout: number;
scale: "css";
threshold: number;
maxDiffPixelRatio: number;
};
export type TakeScreenshotOptions = PartialWithUndefined<{
/** If no locator is provided then the whole page is use. */
locator: Readonly<Locator>;
}> & Partial<LocatorScreenshotOptions>;
/**
* Get the path to save the given screenshot file name to.
*
* @category Internal
*/
export declare function getScreenshotPath(testContext: Readonly<UniversalTestContext>, screenshotBaseName: string): string;
/**
* Options for taking _and_ saving a screenshot.
*
* @category Internal
*/
export type SaveScreenshotOptions = TakeScreenshotOptions & {
screenshotBaseName: string;
};
/**
* Take and immediately save a screenshot.
*
* @category Internal
* @returns The path that the screenshot was saved to.
*/
export declare function takeScreenshot(testContext: Readonly<UniversalTestContext>, options: Readonly<SaveScreenshotOptions>): Promise<string>;
/**
* Similar to Playwright's `expect().toHaveScreenshot` but allows images to have different sizes and
* has default comparison threshold options that are wide enough to allow testing between different
* operating systems without failure (usually).
*
* @category Internal
*/
export declare function expectScreenshot(testContext: Readonly<UniversalTestContext>, options: Readonly<SaveScreenshotOptions>): Promise<void>;
export {};