vitest-plugin-vis 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/client/expect/augment.d.ts +8 -0
- package/esm/client/expect/augment.d.ts.map +1 -0
- package/esm/client/expect/augment.js +1 -0
- package/esm/client/expect/extend.d.ts +1 -7
- package/esm/client/expect/extend.d.ts.map +1 -1
- package/esm/client/expect/extend.js +1 -0
- package/esm/client/expect/to_match_image_snapshot.d.ts.map +1 -1
- package/esm/client/expect/to_match_image_snapshot.js +3 -2
- package/esm/client/expect/to_match_image_snapshot.types.d.ts +5 -0
- package/esm/client/expect/to_match_image_snapshot.types.d.ts.map +1 -1
- package/esm/client/match_image_snapshot.d.ts +4 -1
- package/esm/client/match_image_snapshot.d.ts.map +1 -1
- package/esm/client/match_image_snapshot.js +43 -30
- package/esm/client/match_image_snapshot.logic.js +1 -1
- package/esm/client/page/augment.d.ts +6 -0
- package/esm/client/page/augment.d.ts.map +1 -0
- package/esm/client/page/augment.js +1 -0
- package/esm/client/page/extend.d.ts +1 -5
- package/esm/client/page/extend.d.ts.map +1 -1
- package/esm/client/page/extend.js +1 -0
- package/esm/client/selector.d.ts +0 -2
- package/esm/client/selector.d.ts.map +1 -1
- package/esm/client/selector.js +5 -12
- package/esm/commands.d.ts +2 -0
- package/esm/commands.d.ts.map +1 -1
- package/esm/commands.js +2 -0
- package/esm/config/vis.d.ts +1 -1
- package/esm/index.d.ts +2 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +2 -0
- package/esm/presets/auto.d.ts +2 -1
- package/esm/presets/auto.d.ts.map +1 -1
- package/esm/presets/auto.js +2 -1
- package/esm/presets/manual.d.ts +2 -1
- package/esm/presets/manual.d.ts.map +1 -1
- package/esm/presets/manual.js +2 -1
- package/esm/server/commands/_assertions.d.ts +5 -0
- package/esm/server/commands/_assertions.d.ts.map +1 -0
- package/esm/server/commands/_assertions.js +11 -0
- package/esm/server/commands/extend.d.ts +1 -1
- package/esm/server/commands/has_image_snapshot.d.ts.map +1 -1
- package/esm/server/commands/has_image_snapshot.js +2 -3
- package/esm/server/commands/image_snapshot_next_index.d.ts.map +1 -1
- package/esm/server/commands/image_snapshot_next_index.js +2 -3
- package/esm/server/commands/match_image_snapshot.d.ts.map +1 -1
- package/esm/server/commands/match_image_snapshot.js +6 -5
- package/esm/server/commands/prepare_image_snapshot_comparison.d.ts.map +1 -1
- package/esm/server/commands/prepare_image_snapshot_comparison.js +2 -3
- package/esm/server/commands/setup_vis_suite.d.ts.map +1 -1
- package/esm/server/commands/setup_vis_suite.js +2 -0
- package/esm/server/commands/write_image_snapshot.d.ts +8 -2
- package/esm/server/commands/write_image_snapshot.d.ts.map +1 -1
- package/esm/server/commands/write_image_snapshot.js +6 -7
- package/esm/server/vis_context.d.ts.map +1 -1
- package/esm/server/vis_context.logic.d.ts +2 -2
- package/esm/server/vis_context.logic.d.ts.map +1 -1
- package/esm/server/vis_context.logic.js +3 -3
- package/esm/shared/compare_image.d.ts +6 -0
- package/esm/shared/compare_image.d.ts.map +1 -0
- package/esm/shared/compare_image.js +10 -0
- package/esm/testing/stubBrowserCommandContext.d.ts +3 -0
- package/esm/testing/stubBrowserCommandContext.d.ts.map +1 -0
- package/esm/testing/stubBrowserCommandContext.js +2 -0
- package/esm/testing.d.ts +1 -0
- package/esm/testing.d.ts.map +1 -1
- package/esm/testing.js +1 -0
- package/package.json +2 -1
- package/readme.md +38 -2
- package/src/client/expect/augment.ts +8 -0
- package/src/client/expect/extend.ts +1 -8
- package/src/client/expect/to_match_image_snapshot.ts +3 -2
- package/src/client/expect/to_match_image_snapshot.types.ts +7 -1
- package/src/client/match_image_snapshot.logic.ts +1 -1
- package/src/client/match_image_snapshot.ts +68 -36
- package/src/client/page/augment.ts +5 -0
- package/src/client/page/extend.ts +2 -5
- package/src/client/selector.ts +0 -13
- package/src/commands.ts +2 -0
- package/src/index.ts +3 -0
- package/src/presets/auto.ts +2 -1
- package/src/presets/manual.ts +2 -1
- package/src/server/commands/_assertions.ts +18 -0
- package/src/server/commands/has_image_snapshot.ts +2 -3
- package/src/server/commands/image_snapshot_next_index.ts +2 -3
- package/src/server/commands/match_image_snapshot.ts +13 -6
- package/src/server/commands/prepare_image_snapshot_comparison.ts +2 -3
- package/src/server/commands/setup_vis_suite.ts +3 -0
- package/src/server/commands/write_image_snapshot.ts +17 -11
- package/src/server/vis_context.logic.ts +6 -6
- package/src/shared/compare_image.ts +20 -0
- package/src/testing/stubBrowserCommandContext.ts +4 -0
- package/src/testing.ts +1 -0
- package/esm/client/compare_image.d.ts +0 -7
- package/esm/client/compare_image.d.ts.map +0 -1
- package/esm/client/compare_image.js +0 -13
- package/esm/server/commands/is_ci.d.ts +0 -2
- package/esm/server/commands/is_ci.d.ts.map +0 -1
- package/esm/server/commands/is_ci.js +0 -6
- package/esm/server/compare_image.d.ts +0 -8
- package/esm/server/compare_image.d.ts.map +0 -1
- package/esm/server/compare_image.js +0 -16
- package/src/client/compare_image.ts +0 -21
- package/src/server/commands/is_ci.ts +0 -7
- package/src/server/compare_image.ts +0 -34
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import pixelmatch from 'pixelmatch'
|
|
2
|
+
import { convertThresholdUnit } from './convert_threshold_unit.ts'
|
|
3
|
+
import type { ImageSnapshotCompareOptions } from './types.ts'
|
|
4
|
+
|
|
5
|
+
export function compareImage(
|
|
6
|
+
img1: Uint8ClampedArray | Buffer,
|
|
7
|
+
img2: Uint8ClampedArray | Buffer,
|
|
8
|
+
output: Uint8ClampedArray | Buffer,
|
|
9
|
+
width: number,
|
|
10
|
+
height: number,
|
|
11
|
+
{ failureThreshold = 0, failureThresholdType = 'pixel', diffOptions }: ImageSnapshotCompareOptions = {},
|
|
12
|
+
) {
|
|
13
|
+
const pixelDiff = pixelmatch(img1, img2, output, width, height, diffOptions)
|
|
14
|
+
const diffAmount = convertThresholdUnit({ failureThresholdType, width, height }, pixelDiff)
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
pass: diffAmount <= failureThreshold,
|
|
18
|
+
diffAmount,
|
|
19
|
+
}
|
|
20
|
+
}
|
package/src/testing.ts
CHANGED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { ImageSnapshotCompareOptions } from '../shared/types.ts';
|
|
2
|
-
export declare function compareImage(baselineImage: ImageData, resultImage: ImageData, { failureThreshold, failureThresholdType, diffOptions }?: ImageSnapshotCompareOptions): {
|
|
3
|
-
pass: boolean;
|
|
4
|
-
diffAmount: number;
|
|
5
|
-
diffImage: ImageData;
|
|
6
|
-
};
|
|
7
|
-
//# sourceMappingURL=compare_image.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compare_image.d.ts","sourceRoot":"","sources":["../../src/client/compare_image.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAA;AAErE,wBAAgB,YAAY,CAC3B,aAAa,EAAE,SAAS,EACxB,WAAW,EAAE,SAAS,EACtB,EAAE,gBAAoB,EAAE,oBAA8B,EAAE,WAAW,EAAE,GAAE,2BAAgC;;;;EAavG"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import pixelmatch from 'pixelmatch';
|
|
2
|
-
import { convertThresholdUnit } from "../shared/convert_threshold_unit.js";
|
|
3
|
-
export function compareImage(baselineImage, resultImage, { failureThreshold = 0, failureThresholdType = 'pixel', diffOptions } = {}) {
|
|
4
|
-
const { width, height } = resultImage;
|
|
5
|
-
const diffImage = new ImageData(width, height);
|
|
6
|
-
const pixelDiff = pixelmatch(resultImage.data, baselineImage.data, diffImage.data, width, height, diffOptions);
|
|
7
|
-
const diffAmount = convertThresholdUnit({ failureThresholdType, width, height }, pixelDiff);
|
|
8
|
-
return {
|
|
9
|
-
pass: diffAmount <= failureThreshold,
|
|
10
|
-
diffAmount,
|
|
11
|
-
diffImage,
|
|
12
|
-
};
|
|
13
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is_ci.d.ts","sourceRoot":"","sources":["../../../src/server/commands/is_ci.ts"],"names":[],"mappings":""}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { PNG } from 'pngjs';
|
|
2
|
-
import type { ImageSnapshotCompareOptions } from '../shared/types.ts';
|
|
3
|
-
export declare function compareImage(baselineImage: PNG, resultImage: PNG, { failureThreshold, failureThresholdType, diffOptions }?: ImageSnapshotCompareOptions): {
|
|
4
|
-
pass: boolean;
|
|
5
|
-
diffAmount: number;
|
|
6
|
-
diffImage: PNG;
|
|
7
|
-
};
|
|
8
|
-
//# sourceMappingURL=compare_image.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compare_image.d.ts","sourceRoot":"","sources":["../../src/server/compare_image.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAE3B,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAA;AAErE,wBAAgB,YAAY,CAC3B,aAAa,EAAE,GAAG,EAClB,WAAW,EAAE,GAAG,EAChB,EAAE,gBAAoB,EAAE,oBAA8B,EAAE,WAAW,EAAE,GAAE,2BAAgC;;;;EAyBvG"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import pixelmatch from 'pixelmatch';
|
|
2
|
-
import { PNG } from 'pngjs';
|
|
3
|
-
import { convertThresholdUnit } from "../shared/convert_threshold_unit.js";
|
|
4
|
-
export function compareImage(baselineImage, resultImage, { failureThreshold = 0, failureThresholdType = 'pixel', diffOptions } = {}) {
|
|
5
|
-
const diffImage = new PNG({
|
|
6
|
-
width: baselineImage.width,
|
|
7
|
-
height: baselineImage.height,
|
|
8
|
-
});
|
|
9
|
-
const pixelDiff = pixelmatch(resultImage.data, baselineImage.data, diffImage.data, baselineImage.width, baselineImage.height, diffOptions);
|
|
10
|
-
const diffAmount = convertThresholdUnit({ failureThresholdType, width: baselineImage.width, height: baselineImage.height }, pixelDiff);
|
|
11
|
-
return {
|
|
12
|
-
pass: diffAmount <= failureThreshold,
|
|
13
|
-
diffAmount,
|
|
14
|
-
diffImage,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import pixelmatch from 'pixelmatch'
|
|
2
|
-
import { convertThresholdUnit } from '../shared/convert_threshold_unit.ts'
|
|
3
|
-
import type { ImageSnapshotCompareOptions } from '../shared/types.ts'
|
|
4
|
-
|
|
5
|
-
export function compareImage(
|
|
6
|
-
baselineImage: ImageData,
|
|
7
|
-
resultImage: ImageData,
|
|
8
|
-
{ failureThreshold = 0, failureThresholdType = 'pixel', diffOptions }: ImageSnapshotCompareOptions = {},
|
|
9
|
-
) {
|
|
10
|
-
const { width, height } = resultImage
|
|
11
|
-
const diffImage = new ImageData(width, height)
|
|
12
|
-
|
|
13
|
-
const pixelDiff = pixelmatch(resultImage.data, baselineImage.data, diffImage.data, width, height, diffOptions)
|
|
14
|
-
const diffAmount = convertThresholdUnit({ failureThresholdType, width, height }, pixelDiff)
|
|
15
|
-
|
|
16
|
-
return {
|
|
17
|
-
pass: diffAmount <= failureThreshold,
|
|
18
|
-
diffAmount,
|
|
19
|
-
diffImage,
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import pixelmatch from 'pixelmatch'
|
|
2
|
-
import { PNG } from 'pngjs'
|
|
3
|
-
import { convertThresholdUnit } from '../shared/convert_threshold_unit.ts'
|
|
4
|
-
import type { ImageSnapshotCompareOptions } from '../shared/types.ts'
|
|
5
|
-
|
|
6
|
-
export function compareImage(
|
|
7
|
-
baselineImage: PNG,
|
|
8
|
-
resultImage: PNG,
|
|
9
|
-
{ failureThreshold = 0, failureThresholdType = 'pixel', diffOptions }: ImageSnapshotCompareOptions = {},
|
|
10
|
-
) {
|
|
11
|
-
const diffImage = new PNG({
|
|
12
|
-
width: baselineImage.width,
|
|
13
|
-
height: baselineImage.height,
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
const pixelDiff = pixelmatch(
|
|
17
|
-
resultImage.data,
|
|
18
|
-
baselineImage.data,
|
|
19
|
-
diffImage.data,
|
|
20
|
-
baselineImage.width,
|
|
21
|
-
baselineImage.height,
|
|
22
|
-
diffOptions,
|
|
23
|
-
)
|
|
24
|
-
const diffAmount = convertThresholdUnit(
|
|
25
|
-
{ failureThresholdType, width: baselineImage.width, height: baselineImage.height },
|
|
26
|
-
pixelDiff,
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
return {
|
|
30
|
-
pass: diffAmount <= failureThreshold,
|
|
31
|
-
diffAmount,
|
|
32
|
-
diffImage,
|
|
33
|
-
}
|
|
34
|
-
}
|