mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Update types for jest-image-snapshots 4.1.0 (#47102)
* update types for jest-image-snapshots 4.1.0 * Fix type definition comment version * include package.json for ssim.js in jest-image-snapshots * include dom library
This commit is contained in:
parent
0dab26a3e9
commit
751f0a5544
31
types/jest-image-snapshot/index.d.ts
vendored
31
types/jest-image-snapshot/index.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
// Type definitions for jest-image-snapshot 3.1
|
||||
// Type definitions for jest-image-snapshot 4.1
|
||||
// Project: https://github.com/americanexpress/jest-image-snapshot#readme
|
||||
// Definitions by: Janeene Beeforth <https://github.com/dawnmist>
|
||||
// erbridge <https://github.com/erbridge>
|
||||
@ -7,23 +7,8 @@
|
||||
// TypeScript Version: 3.1
|
||||
|
||||
/// <reference types="jest" />
|
||||
|
||||
/**
|
||||
* Options to be passed to the 'pixelmatch' image diffing function.
|
||||
*/
|
||||
export interface PixelmatchOptions {
|
||||
/**
|
||||
* Matching threshold, ranges from 0 to 1.
|
||||
* Smaller values make the comparison more sensitive.
|
||||
* @default 0.1
|
||||
*/
|
||||
readonly threshold?: number;
|
||||
/**
|
||||
* If true, disables detecting and ignoring anti-aliased pixels.
|
||||
* @default false
|
||||
*/
|
||||
readonly includeAA?: boolean;
|
||||
}
|
||||
import { PixelmatchOptions } from 'pixelmatch';
|
||||
import { Options as SSIMOptions } from 'ssim.js';
|
||||
|
||||
export interface MatchImageSnapshotOptions {
|
||||
/**
|
||||
@ -32,9 +17,15 @@ export interface MatchImageSnapshotOptions {
|
||||
*/
|
||||
allowSizeMismatch?: boolean;
|
||||
/**
|
||||
* Custom config passed to 'pixelmatch'
|
||||
* Custom config passed to 'pixelmatch' or 'ssim'
|
||||
*/
|
||||
customDiffConfig?: PixelmatchOptions;
|
||||
customDiffConfig?: PixelmatchOptions | SSIMOptions;
|
||||
/**
|
||||
* The method by which images are compared.
|
||||
* `pixelmatch` does a pixel by pixel comparison, whereas `ssim` does a structural similarity comparison.
|
||||
* @default 'pixelmatch'
|
||||
*/
|
||||
comparisonMethod?: 'pixelmatch' | 'ssim';
|
||||
/**
|
||||
* Custom snapshots directory.
|
||||
* Absolute path of a directory to keep the snapshot in.
|
||||
|
||||
6
types/jest-image-snapshot/package.json
Normal file
6
types/jest-image-snapshot/package.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"ssim.js": "^3.1.0"
|
||||
}
|
||||
}
|
||||
@ -2,7 +2,8 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
|
||||
84
types/pixelmatch/index.d.ts
vendored
84
types/pixelmatch/index.d.ts
vendored
@ -19,50 +19,52 @@ declare function Pixelmatch(
|
||||
/** Height of the images. Note that all three images need to have the same dimensions. */
|
||||
height: number,
|
||||
/** Options. */
|
||||
options?: Options,
|
||||
options?: Pixelmatch.PixelmatchOptions,
|
||||
): number;
|
||||
|
||||
type RGBTuple = [number, number, number];
|
||||
declare namespace Pixelmatch {
|
||||
type RGBTuple = [number, number, number];
|
||||
|
||||
interface Options {
|
||||
/**
|
||||
* Matching threshold, ranges from 0 to 1. Smaller values make the comparison more sensitive.
|
||||
* @default 0.1
|
||||
*/
|
||||
readonly threshold?: number;
|
||||
/**
|
||||
* If true, disables detecting and ignoring anti-aliased pixels.
|
||||
* @default false
|
||||
*/
|
||||
readonly includeAA?: boolean;
|
||||
/**
|
||||
* Blending factor of unchanged pixels in the diff output.
|
||||
* Ranges from 0 for pure white to 1 for original brightness
|
||||
* @default 0.1
|
||||
*/
|
||||
alpha?: number;
|
||||
/**
|
||||
* The color of anti-aliased pixels in the diff output.
|
||||
* @default [255, 255, 0]
|
||||
*/
|
||||
aaColor?: RGBTuple;
|
||||
/**
|
||||
* The color of differing pixels in the diff output.
|
||||
* @default [255, 0, 0]
|
||||
*/
|
||||
diffColor?: RGBTuple;
|
||||
/**
|
||||
* An alternative color to use for dark on light differences to differentiate between "added" and "removed" parts.
|
||||
* If not provided, all differing pixels use the color specified by `diffColor`.
|
||||
* @default null
|
||||
*/
|
||||
diffColorAlt?: RGBTuple;
|
||||
/**
|
||||
* Draw the diff over a transparent background (a mask), rather than over the original image.
|
||||
* Will not draw anti-aliased pixels (if detected)
|
||||
* @default false
|
||||
*/
|
||||
diffMask?: boolean;
|
||||
interface PixelmatchOptions {
|
||||
/**
|
||||
* Matching threshold, ranges from 0 to 1. Smaller values make the comparison more sensitive.
|
||||
* @default 0.1
|
||||
*/
|
||||
readonly threshold?: number;
|
||||
/**
|
||||
* If true, disables detecting and ignoring anti-aliased pixels.
|
||||
* @default false
|
||||
*/
|
||||
readonly includeAA?: boolean;
|
||||
/**
|
||||
* Blending factor of unchanged pixels in the diff output.
|
||||
* Ranges from 0 for pure white to 1 for original brightness
|
||||
* @default 0.1
|
||||
*/
|
||||
alpha?: number;
|
||||
/**
|
||||
* The color of anti-aliased pixels in the diff output.
|
||||
* @default [255, 255, 0]
|
||||
*/
|
||||
aaColor?: RGBTuple;
|
||||
/**
|
||||
* The color of differing pixels in the diff output.
|
||||
* @default [255, 0, 0]
|
||||
*/
|
||||
diffColor?: RGBTuple;
|
||||
/**
|
||||
* An alternative color to use for dark on light differences to differentiate between "added" and "removed" parts.
|
||||
* If not provided, all differing pixels use the color specified by `diffColor`.
|
||||
* @default null
|
||||
*/
|
||||
diffColorAlt?: RGBTuple;
|
||||
/**
|
||||
* Draw the diff over a transparent background (a mask), rather than over the original image.
|
||||
* Will not draw anti-aliased pixels (if detected)
|
||||
* @default false
|
||||
*/
|
||||
diffMask?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
export = Pixelmatch;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user