From 9785fa3b5ad07167ef7f4c1ce7c8ec068c6d62cc Mon Sep 17 00:00:00 2001 From: Alex Kessock Date: Tue, 28 Jan 2020 10:57:03 -0700 Subject: [PATCH] Add options from cypress and jest-image-snapshot to cypress-image-snapshot (#41897) * Add options from cypress and jest-image-snapshot to cypress-image-snapshot * Use jest-image-snapshot from DefinitelyTyped * Don't use relative paths to DefinitelyTyped modules * Use TypeScript Version: 3.0 to match jest-image-snapshot * inline jest-image-snapshot * Don't use include * Add dom to tsconfig * Don't export MatchImageSnapshotOptions --- .../cypress-image-snapshot-tests.ts | 1 + types/cypress-image-snapshot/index.d.ts | 38 ++++++++++++++----- types/cypress-image-snapshot/package.json | 6 +++ types/cypress-image-snapshot/tsconfig.json | 13 ++----- 4 files changed, 38 insertions(+), 20 deletions(-) create mode 100644 types/cypress-image-snapshot/package.json diff --git a/types/cypress-image-snapshot/cypress-image-snapshot-tests.ts b/types/cypress-image-snapshot/cypress-image-snapshot-tests.ts index f35fb2e86d..e9eb1e08e2 100644 --- a/types/cypress-image-snapshot/cypress-image-snapshot-tests.ts +++ b/types/cypress-image-snapshot/cypress-image-snapshot-tests.ts @@ -4,6 +4,7 @@ import { addMatchImageSnapshotPlugin } from 'cypress-image-snapshot/plugin'; // $ExpectType void command.addMatchImageSnapshotCommand({ customSnapshotsDir: '../../test/cypress/snapshots', + scale: true, }); addMatchImageSnapshotPlugin(() => null, {}); // $ExpectType void diff --git a/types/cypress-image-snapshot/index.d.ts b/types/cypress-image-snapshot/index.d.ts index ddd47b4be5..7812678d70 100644 --- a/types/cypress-image-snapshot/index.d.ts +++ b/types/cypress-image-snapshot/index.d.ts @@ -3,16 +3,34 @@ // Definitions by: Alex Kessock // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -export interface Options { - customSnapshotsDir?: string; - customDiffDir?: string; - failureThreshold?: number; - failureThresholdType?: 'percent' | 'number'; - customDiffConfig?: { - threshold: number; - }; - capture?: 'viewport'; -} +/// + +export interface Options + extends Partial< + Cypress.ScreenshotOptions & { + customDiffConfig?: { + readonly threshold?: number; + readonly includeAA?: boolean; + }; + customSnapshotsDir?: string; + customDiffDir?: string; + customSnapshotIdentifier?: + | ((parameters: { + testPath: string; + currentTestName: string; + counter: number; + defaultIdentifier: string; + }) => string) + | string; + diffDirection?: 'horizontal' | 'vertical'; + noColors?: boolean; + failureThreshold?: number; + failureThresholdType?: 'pixel' | 'percent'; + updatePassedSnapshot?: boolean; + blur?: number; + runInProcess?: boolean; + } + > {} declare global { namespace Cypress { diff --git a/types/cypress-image-snapshot/package.json b/types/cypress-image-snapshot/package.json new file mode 100644 index 0000000000..95d6480360 --- /dev/null +++ b/types/cypress-image-snapshot/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "cypress": "^3.8.3" + } +} diff --git a/types/cypress-image-snapshot/tsconfig.json b/types/cypress-image-snapshot/tsconfig.json index c7488a07f3..5bebc03fbb 100644 --- a/types/cypress-image-snapshot/tsconfig.json +++ b/types/cypress-image-snapshot/tsconfig.json @@ -1,23 +1,16 @@ { "compilerOptions": { "module": "commonjs", - "lib": [ - "es6" - ], + "lib": ["es6", "dom"], "noImplicitAny": true, "noImplicitThis": true, "strictFunctionTypes": true, "strictNullChecks": true, "baseUrl": "../", - "typeRoots": [ - "../" - ], + "typeRoots": ["../"], "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, - "files": [ - "index.d.ts", - "cypress-image-snapshot-tests.ts" - ] + "files": ["index.d.ts", "cypress-image-snapshot-tests.ts"] }