@argos-ci/browser
Version:
Browser utilities to stabilize visual testing with Argos.
194 lines (188 loc) • 5.01 kB
TypeScript
type ViewportOrientation = "portrait" | "landscape";
type ViewportSize = {
width: number;
height: number;
};
declare const viewportPresets: {
readonly "macbook-16": {
readonly width: 1536;
readonly height: 960;
};
readonly "macbook-15": {
readonly width: 1440;
readonly height: 900;
};
readonly "macbook-13": {
readonly width: 1280;
readonly height: 800;
};
readonly "macbook-11": {
readonly width: 1366;
readonly height: 768;
};
readonly "ipad-2": {
readonly width: 768;
readonly height: 1024;
};
readonly "ipad-mini": {
readonly width: 768;
readonly height: 1024;
};
readonly "iphone-xr": {
readonly width: 414;
readonly height: 896;
};
readonly "iphone-x": {
readonly width: 375;
readonly height: 812;
};
readonly "iphone-6+": {
readonly width: 414;
readonly height: 736;
};
readonly "iphone-se2": {
readonly width: 375;
readonly height: 667;
};
readonly "iphone-8": {
readonly width: 375;
readonly height: 667;
};
readonly "iphone-7": {
readonly width: 375;
readonly height: 667;
};
readonly "iphone-6": {
readonly width: 375;
readonly height: 667;
};
readonly "iphone-5": {
readonly width: 320;
readonly height: 568;
};
readonly "iphone-4": {
readonly width: 320;
readonly height: 480;
};
readonly "iphone-3": {
readonly width: 320;
readonly height: 480;
};
readonly "samsung-s10": {
readonly width: 360;
readonly height: 760;
};
readonly "samsung-note9": {
readonly width: 414;
readonly height: 846;
};
};
type ViewportPreset = keyof typeof viewportPresets;
type ViewportPresetOption = {
preset: ViewportPreset;
orientation?: ViewportOrientation;
};
type ViewportOption = ViewportSize | ViewportPresetOption | ViewportPreset;
declare function resolveViewport(viewportOption: ViewportOption): ViewportSize;
declare const plugins: ({
name: "disableSpellcheck";
beforeAll(): () => void;
} | {
name: "fontAntialiasing";
beforeAll(): () => void;
} | {
name: "hideCarets";
beforeAll(): () => void;
} | {
name: "hideScrollbars";
beforeAll(): () => void;
} | {
name: "loadImageSrcset";
beforeEach(options: RuntimeContext): undefined;
} | {
name: "roundImageSize";
beforeEach(): () => void;
} | {
name: "stabilizeSticky";
beforeAll(options: RuntimeContext): (() => void) | undefined;
} | {
name: "waitForAriaBusy";
wait: {
for: () => boolean;
failureExplanation: string;
};
} | {
name: "waitForFonts";
wait: {
for: () => boolean;
failureExplanation: string;
};
} | {
name: "waitForImages";
beforeEach(): undefined;
wait: {
for: () => boolean;
failureExplanation: string;
};
})[];
type PluginName = (typeof plugins)[number]["name"];
interface RuntimeContext {
/**
* Is the test running in full page mode?
*/
fullPage?: boolean;
/**
* Viewports to use for the test.
*/
viewports?: ViewportOption[];
/**
* Custom CSS to apply to the page before taking a screenshot.
*/
argosCSS?: string;
}
type PluginOptions = {
[key in PluginName]?: boolean;
};
interface Context extends RuntimeContext {
options?: PluginOptions | boolean;
}
/**
* Run before taking all screenshots.
*/
declare function beforeAll(context?: Context): void;
/**
* Run after taking all screenshots.
*/
declare function afterAll(): void;
/**
* Run before taking each screenshot (between viewport changes).
*/
declare function beforeEach(context?: Context): void;
/**
* Run after taking each screenshot (between viewport changes).
*/
declare function afterEach(): void;
/**
* Wait for a condition to be met before taking a screenshot.
*/
declare function waitFor(context: Context): boolean;
/**
* Get the error message to display if the condition is not met.
*/
declare function getWaitFailureExplanations(options: Context): string[];
declare const ArgosGlobal: {
beforeAll: typeof beforeAll;
afterAll: typeof afterAll;
beforeEach: typeof beforeEach;
afterEach: typeof afterEach;
waitFor: typeof waitFor;
getWaitFailureExplanations: typeof getWaitFailureExplanations;
getColorScheme: () => "dark" | "light";
getMediaType: () => "print" | "screen";
};
type ArgosGlobal = typeof ArgosGlobal;
/**
* Read the global script and return it as a string.
*/
declare function getGlobalScript(): string;
export { ArgosGlobal, type Context as StabilizationContext, type PluginOptions as StabilizationPluginOptions, type ViewportOption, type ViewportOrientation, type ViewportPreset, type ViewportPresetOption, type ViewportSize, getGlobalScript, resolveViewport };