Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add options from cypress and jest-image-snapshot to cypress-image-snapshot #41897

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
38 changes: 28 additions & 10 deletions types/cypress-image-snapshot/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,34 @@
// Definitions by: Alex Kessock <https://github.com/Keysox>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

export interface Options {
customSnapshotsDir?: string;
customDiffDir?: string;
failureThreshold?: number;
failureThresholdType?: 'percent' | 'number';
customDiffConfig?: {
threshold: number;
};
capture?: 'viewport';
}
/// <reference types="Cypress" />

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 {
Expand Down
6 changes: 6 additions & 0 deletions types/cypress-image-snapshot/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"cypress": "^3.8.3"
}
}
13 changes: 3 additions & 10 deletions types/cypress-image-snapshot/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"]
}