vitest-plugin-vis 1.3.0 → 1.3.2

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.
@@ -1,6 +1,6 @@
1
1
  import { commands } from '@vitest/browser/context';
2
2
  import { ctx } from "../ctx.js";
3
- import { imageSnapshotMatcher } from "../match_image_snapshot.js";
3
+ import { imageSnapshotMatcher } from "../image_snapshot_matcher.js";
4
4
  import { success } from "./expectation_result.js";
5
5
  export function toMatchImageSnapshot(
6
6
  /**
@@ -8,4 +8,4 @@ export declare function imageSnapshotMatcher(commands: PrepareImageSnapshotCompa
8
8
  * @deprecated internalized. Use `matchImageSnapshot` directly instead.
9
9
  */
10
10
  export declare function parseImageSnapshotSubject(subject: any): any;
11
- //# sourceMappingURL=match_image_snapshot.d.ts.map
11
+ //# sourceMappingURL=image_snapshot_matcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image_snapshot_matcher.d.ts","sourceRoot":"","sources":["../../src/client/image_snapshot_matcher.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAClC,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAA;AACnE,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,yDAAyD,CAAA;AACpH,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAA;AAI3F,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,2CAA2C,CAAA;AAO5F,wBAAgB,oBAAoB,CACnC,QAAQ,EAAE,qCAAqC,GAAG,yBAAyB,GAAG,6BAA6B,UAE5D,IAAI,WAAW,GAAG,YAAY,2BAA2B,mBA8DxG;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,GAAG,OAOrD"}
@@ -4,7 +4,7 @@ import { isBase64String } from "../shared/base64.js";
4
4
  import { compareImage } from "../shared/compare_image.js";
5
5
  import { alignImagesToSameSize } from "./align_images.js";
6
6
  import { toDataURL, toImageData } from "./image_data.js";
7
- import { prettifyOptions } from "./match_image_snapshot.logic.js";
7
+ import { prettifyOptions } from "./image_snapshot_matcher.logic.js";
8
8
  import { convertElementToCssSelector } from "./selector.js";
9
9
  import { toTaskId } from "./task_id.js";
10
10
  import { server } from "./vitest_browser_context_proxy.js";
@@ -25,14 +25,14 @@ export function imageSnapshotMatcher(commands) {
25
25
  throw new Error(dedent `Snapshot \`${taskId}\` matched but expected to fail.
26
26
 
27
27
  Options: ${prettifyOptions(options)}
28
- DiffAmount: ${options.failureThresholdType === 'percent' ? `${diffAmount}%` : `${diffAmount} pixels`}
28
+ Diff: ${options.failureThresholdType === 'percent' ? `${diffAmount}%` : `${diffAmount} pixels`}
29
29
 
30
30
  Expected: ${resolve(info.projectRoot, info.baselinePath)}
31
31
  Actual: ${resolve(info.projectRoot, info.resultPath)}`);
32
32
  }
33
33
  return;
34
34
  }
35
- if (server.config.snapshotOptions.updateSnapshot === 'all') {
35
+ if (server.config.snapshotOptions.updateSnapshot === 'all' && !options?.expectToFail) {
36
36
  await writeSnapshot(commands, info.baselinePath, resultImage);
37
37
  return;
38
38
  }
@@ -1,3 +1,3 @@
1
1
  import type { ToMatchImageSnapshotOptions } from './expect/to_match_image_snapshot.types.ts';
2
2
  export declare function prettifyOptions(options: ToMatchImageSnapshotOptions | undefined): string;
3
- //# sourceMappingURL=match_image_snapshot.logic.d.ts.map
3
+ //# sourceMappingURL=image_snapshot_matcher.logic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image_snapshot_matcher.logic.d.ts","sourceRoot":"","sources":["../../src/client/image_snapshot_matcher.logic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,2CAA2C,CAAA;AAE5F,wBAAgB,eAAe,CAAC,OAAO,EAAE,2BAA2B,GAAG,SAAS,UAU/E"}
package/esm/client.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export * from './client/expect/expectation_result.ts';
2
2
  export type * from './client/expect/to_match_image_snapshot.types.ts';
3
- export * from './client/match_image_snapshot.ts';
3
+ export * from './client/image_snapshot_matcher.ts';
4
4
  export * from './client/should_take_snapshot.ts';
5
5
  export * from './client/snapshot_options.ts';
6
6
  export * from './client/task_id.ts';
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,cAAc,uCAAuC,CAAA;AACrD,mBAAmB,kDAAkD,CAAA;AACrE,cAAc,kCAAkC,CAAA;AAChD,cAAc,kCAAkC,CAAA;AAChD,cAAc,8BAA8B,CAAA;AAC5C,cAAc,qBAAqB,CAAA;AACnC,mBAAmB,mBAAmB,CAAA"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,cAAc,uCAAuC,CAAA;AACrD,mBAAmB,kDAAkD,CAAA;AACrE,cAAc,oCAAoC,CAAA;AAClD,cAAc,kCAAkC,CAAA;AAChD,cAAc,8BAA8B,CAAA;AAC5C,cAAc,qBAAqB,CAAA;AACnC,mBAAmB,mBAAmB,CAAA"}
package/esm/client.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export * from "./client/expect/expectation_result.js";
2
- export * from "./client/match_image_snapshot.js";
2
+ export * from "./client/image_snapshot_matcher.js";
3
3
  export * from "./client/should_take_snapshot.js";
4
4
  export * from "./client/snapshot_options.js";
5
5
  export * from "./client/task_id.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest-plugin-vis",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "Vitest visual testing plugin",
5
5
  "keywords": [
6
6
  "image-snapshot",
@@ -1,7 +1,7 @@
1
1
  import { commands } from '@vitest/browser/context'
2
2
  import type { AsyncExpectationResult } from '@vitest/expect'
3
3
  import { ctx } from '../ctx.ts'
4
- import { imageSnapshotMatcher } from '../match_image_snapshot.ts'
4
+ import { imageSnapshotMatcher } from '../image_snapshot_matcher.ts'
5
5
  import { success } from './expectation_result.ts'
6
6
  import type { ToMatchImageSnapshotOptions } from './to_match_image_snapshot.types.ts'
7
7
 
@@ -9,7 +9,7 @@ import { compareImage } from '../shared/compare_image.ts'
9
9
  import { alignImagesToSameSize } from './align_images.ts'
10
10
  import type { ToMatchImageSnapshotOptions } from './expect/to_match_image_snapshot.types.ts'
11
11
  import { toDataURL, toImageData } from './image_data.ts'
12
- import { prettifyOptions } from './match_image_snapshot.logic.ts'
12
+ import { prettifyOptions } from './image_snapshot_matcher.logic.ts'
13
13
  import { convertElementToCssSelector } from './selector.ts'
14
14
  import { toTaskId } from './task_id.ts'
15
15
  import { server } from './vitest_browser_context_proxy.ts'
@@ -46,7 +46,7 @@ export function imageSnapshotMatcher(
46
46
  dedent`Snapshot \`${taskId}\` matched but expected to fail.
47
47
 
48
48
  Options: ${prettifyOptions(options)}
49
- DiffAmount: ${options.failureThresholdType === 'percent' ? `${diffAmount}%` : `${diffAmount} pixels`}
49
+ Diff: ${options.failureThresholdType === 'percent' ? `${diffAmount}%` : `${diffAmount} pixels`}
50
50
 
51
51
  Expected: ${resolve(info.projectRoot, info.baselinePath)}
52
52
  Actual: ${resolve(info.projectRoot, info.resultPath)}`,
@@ -54,7 +54,7 @@ export function imageSnapshotMatcher(
54
54
  }
55
55
  return
56
56
  }
57
- if (server.config.snapshotOptions.updateSnapshot === 'all') {
57
+ if (server.config.snapshotOptions.updateSnapshot === 'all' && !options?.expectToFail) {
58
58
  await writeSnapshot(commands, info.baselinePath, resultImage)
59
59
  return
60
60
  }
package/src/client.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export * from './client/expect/expectation_result.ts'
2
2
  export type * from './client/expect/to_match_image_snapshot.types.ts'
3
- export * from './client/match_image_snapshot.ts'
3
+ export * from './client/image_snapshot_matcher.ts'
4
4
  export * from './client/should_take_snapshot.ts'
5
5
  export * from './client/snapshot_options.ts'
6
6
  export * from './client/task_id.ts'
@@ -1 +0,0 @@
1
- {"version":3,"file":"match_image_snapshot.d.ts","sourceRoot":"","sources":["../../src/client/match_image_snapshot.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAClC,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAA;AACnE,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,yDAAyD,CAAA;AACpH,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAA;AAI3F,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,2CAA2C,CAAA;AAO5F,wBAAgB,oBAAoB,CACnC,QAAQ,EAAE,qCAAqC,GAAG,yBAAyB,GAAG,6BAA6B,UAE5D,IAAI,WAAW,GAAG,YAAY,2BAA2B,mBA8DxG;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,GAAG,OAOrD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"match_image_snapshot.logic.d.ts","sourceRoot":"","sources":["../../src/client/match_image_snapshot.logic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,2CAA2C,CAAA;AAE5F,wBAAgB,eAAe,CAAC,OAAO,EAAE,2BAA2B,GAAG,SAAS,UAU/E"}