|
| 1 | +// Type definitions for backstopjs 4.0 |
| 2 | +// Project: https://github.com/garris/backstopjs#readme |
| 3 | +// Definitions by: Darío Blanco <https://github.com/darioblanco>, MindDoc <https://github.com/minddocdev> |
| 4 | +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped |
| 5 | + |
| 6 | +export interface Config { |
| 7 | + asyncCaptureLimit?: number; |
| 8 | + asyncCompareLimit?: number; |
| 9 | + baseUrl?: string; |
| 10 | + ci?: { |
| 11 | + format?: string; |
| 12 | + testReportFileName?: string; |
| 13 | + testSuiteName?: string; |
| 14 | + }; |
| 15 | + debugWindow?: boolean; |
| 16 | + debug?: boolean; |
| 17 | + engine?: 'chromy' | 'puppeteer'; |
| 18 | + engineOptions?: { |
| 19 | + args: string[]; |
| 20 | + chromeFlags?: string[]; |
| 21 | + chromePath?: string; |
| 22 | + ignoreHTTPSErrors?: boolean; |
| 23 | + waitTimeout?: number; |
| 24 | + }; |
| 25 | + id: string; |
| 26 | + onBeforeScript?: string; |
| 27 | + onReadyScript?: string; |
| 28 | + paths?: { |
| 29 | + ci_report?: string; |
| 30 | + bitmaps_reference?: string; |
| 31 | + bitmaps_test?: string; |
| 32 | + engine_scripts?: string; |
| 33 | + html_report?: string; |
| 34 | + json_report?: string; |
| 35 | + }; |
| 36 | + report?: Array<'browser' | 'CI' | 'json'>; |
| 37 | + resembleOutputOptions?: { // See https://github.com/rsmbl/Resemble.js |
| 38 | + errorColor?: { |
| 39 | + red: number; |
| 40 | + green: number; |
| 41 | + blue: number; |
| 42 | + }, |
| 43 | + errorType?: string; |
| 44 | + transparency?: number; |
| 45 | + ignoreAntialiasing?: boolean; |
| 46 | + }; |
| 47 | + scenarios: Scenario[]; |
| 48 | + viewports: Viewport[]; |
| 49 | +} |
| 50 | + |
| 51 | +export interface KeypressSelector { |
| 52 | + selector: string; |
| 53 | + keyPress: string; |
| 54 | +} |
| 55 | + |
| 56 | +/** The Backstop test definition. See https://github.com/garris/BackstopJS#advanced-scenarios */ |
| 57 | +export interface Scenario { |
| 58 | + clickSelector?: string; // Click the specified DOM element prior to screenshot |
| 59 | + clickSelectors?: string[]; // Simulates multiple sequential click interactions |
| 60 | + cookiePath?: string; // Import cookies in JSON format |
| 61 | + delay?: number; // Wait for x milliseconds |
| 62 | + expect?: number; // Use with selectorExpansion true to expect number of results found |
| 63 | + hideSelectors?: string[]; // Selectors set to visibility: hidden |
| 64 | + hoverSelector?: string; // Move pointer over the given DOM element prior to screenshot |
| 65 | + hoverSelectors?: string[]; // Simulates multiple sequential hover interactions |
| 66 | + keyPressSelector?: KeypressSelector; // Press key in the DOM element prior to screenshot |
| 67 | + keyPressSelectors?: KeypressSelector[]; // Simulates multiple sequential keypress interactions |
| 68 | + label: string; // Tag saved with your reference images |
| 69 | + misMatchThreshold?: string; // Percentage of different pixels allowed to pass test |
| 70 | + onBeforeScript?: string; // Used to set up browser state e.g. cookies |
| 71 | + onReadyScript?: string; // Used to modify UI state prior to screenshots e.g. hovers, clicks etc |
| 72 | + postInteractionWait?: number; // Wait for selector (ms) after interacting with hover or click |
| 73 | + readyEvent?: string; // Wait until this string has been logged to the console |
| 74 | + readySelector?: string; // Wait until this selector exists before continuing |
| 75 | + referenceUrl?: string; // Specify a different state or environment when creating reference |
| 76 | + removeSelectors?: string[]; // Selectors set to display: none |
| 77 | + requireSameDimensions?: boolean; // If true, any change in selector size will trigger a failure |
| 78 | + selectors?: string[]; // Selectors to capture |
| 79 | + selectorExpansion?: boolean; // If true, take screenshots of all matching selector instances |
| 80 | + scrollToSelector?: string; // Scroll the specified DOM element into view prior to screenshots |
| 81 | + url: string; // The url of your app state |
| 82 | + viewports?: Viewport[]; // Override global viewports |
| 83 | +} |
| 84 | + |
| 85 | +export interface Viewport { |
| 86 | + name: 'phone' | 'tablet' | 'desktop'; |
| 87 | + width: number; |
| 88 | + height: number; |
| 89 | +} |
| 90 | + |
| 91 | +export default function backstop( |
| 92 | + command: 'approve' | 'init' | 'reference' | 'test', |
| 93 | + options?: { config?: Config | string, filter?: string }, |
| 94 | +): Promise<void>; |
0 commit comments