diff --git a/types/backstopjs/backstopjs-tests.ts b/types/backstopjs/backstopjs-tests.ts index 651d19c67e..1d76815c95 100644 --- a/types/backstopjs/backstopjs-tests.ts +++ b/types/backstopjs/backstopjs-tests.ts @@ -23,7 +23,26 @@ backstop('test', { /** Custom example */ -const scenarios: Scenario[] = [{ label: 'fake', url: 'fakeUrl' }]; +const scenarios: Scenario[] = [ + { + label: 'Microsoft', + url: 'https://microsoft.com/', + referenceUrl: '', + readyEvent: '', + readySelector: '', + delay: 0, + hideSelectors: [], + removeSelectors: [], + hoverSelector: '', + clickSelector: '', + postInteractionWait: 0, + selectors: [], + selectorExpansion: true, + expect: 0, + misMatchThreshold: 0.1, + requireSameDimensions: true, + }, +]; const viewports: Viewport[] = [ { name: 'phone', @@ -40,6 +59,16 @@ const viewports: Viewport[] = [ width: 1280, height: 1024, }, + { + label: 'tablet_v', + width: 1280, + height: 1024, + }, + { + label: 'tablet_h', + width: 1280, + height: 1024, + }, ]; backstop('test', { config: { diff --git a/types/backstopjs/index.d.ts b/types/backstopjs/index.d.ts index 7e760f28ef..e61881fb0a 100644 --- a/types/backstopjs/index.d.ts +++ b/types/backstopjs/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for backstopjs 4.0 +// Type definitions for backstopjs 4.1 // Project: https://github.com/garris/backstopjs#readme // Definitions by: DarĂ­o Blanco , MindDoc // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -55,6 +55,7 @@ export interface KeypressSelector { /** The Backstop test definition. See https://github.com/garris/BackstopJS#advanced-scenarios */ export interface Scenario { + [key: string]: any; // Allow for custom properties. clickSelector?: string; // Click the specified DOM element prior to screenshot clickSelectors?: string[]; // Simulates multiple sequential click interactions cookiePath?: string; // Import cookies in JSON format @@ -66,7 +67,7 @@ export interface Scenario { keyPressSelector?: KeypressSelector; // Press key in the DOM element prior to screenshot keyPressSelectors?: KeypressSelector[]; // Simulates multiple sequential keypress interactions label: string; // Tag saved with your reference images - misMatchThreshold?: string; // Percentage of different pixels allowed to pass test + misMatchThreshold?: number; // Percentage of different pixels allowed to pass test onBeforeScript?: string; // Used to set up browser state e.g. cookies onReadyScript?: string; // Used to modify UI state prior to screenshots e.g. hovers, clicks etc postInteractionWait?: number; // Wait for selector (ms) after interacting with hover or click @@ -82,7 +83,17 @@ export interface Scenario { viewports?: Viewport[]; // Override global viewports } -export interface Viewport { +export type Viewport = ViewportNext | ViewportLegacy; + +export interface ViewportNext { + label: string; + width: number; + height: number; +} + +// Create a Viewport version that uses `name` for legacy support. +// https://github.com/garris/BackstopJS/blob/aa7de8ee059074f947768cfd04db1776348e1a7a/core/util/createBitmaps.js#L25 +export interface ViewportLegacy { name: 'phone' | 'tablet' | 'desktop'; width: number; height: number;