vitest-plugin-vis 1.6.3 → 1.6.4

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 +1 @@
1
- {"version":3,"file":"create_vis.d.ts","sourceRoot":"","sources":["../../src/setup/create_vis.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAA;AAEjF,wBAAgB,SAAS,CAAC,QAAQ,EAAE,oBAAoB;;QAOrD;;WAEG;;QAIH;;;;WAIG;;QAKH;;;;;;;;;;;;;;WAcG;sBACW,MAAM,CAAC,MAAM,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;;;;;;;8BAoBlC,MAAM,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;;EAsClE"}
1
+ {"version":3,"file":"create_vis.d.ts","sourceRoot":"","sources":["../../src/setup/create_vis.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAA;AAEjF,wBAAgB,SAAS,CAAC,QAAQ,EAAE,oBAAoB;;QAOrD;;WAEG;;QAIH;;;;WAIG;;QAKH;;;;;;;;;;;;;;WAcG;sBACW,MAAM,CAAC,MAAM,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;;;;;;;8BAqBlC,MAAM,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;;EAwClE"}
@@ -1,5 +1,5 @@
1
1
  import dedent from 'dedent';
2
- import { afterEach, beforeAll, expect } from 'vitest';
2
+ import { afterEach, beforeAll } from 'vitest';
3
3
  import { toTaskId } from "../client.js";
4
4
  import { ctx } from "../client/ctx.js";
5
5
  import { shouldTakeSnapshot } from "../client/should_take_snapshot.js";
@@ -59,7 +59,7 @@ export function createVis(commands) {
59
59
  const meta = getAutoSnapshotOptions(test);
60
60
  if (!shouldTakeSnapshot(meta))
61
61
  return;
62
- await expect(getSubject(meta?.subjectDataTestId ?? subjectDataTestId)).toMatchImageSnapshot(meta);
62
+ await test.context.expect(getSubject(meta?.subjectDataTestId ?? subjectDataTestId)).toMatchImageSnapshot(meta);
63
63
  },
64
64
  matchPerTheme(themes) {
65
65
  return async function matchImageSnapshot() {
@@ -73,7 +73,9 @@ export function createVis(commands) {
73
73
  for (const themeId in themes) {
74
74
  try {
75
75
  await new Promise((a) => setTimeout(() => a(themes[themeId]()), 10));
76
- await expect(getSubject(meta?.subjectDataTestId ?? subjectDataTestId)).toMatchImageSnapshot({
76
+ await test.context
77
+ .expect(getSubject(meta?.subjectDataTestId ?? subjectDataTestId))
78
+ .toMatchImageSnapshot({
77
79
  ...meta,
78
80
  customizeSnapshotId: (id) => `${id}-${themeId}`,
79
81
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest-plugin-vis",
3
- "version": "1.6.3",
3
+ "version": "1.6.4",
4
4
  "description": "Vitest visual testing plugin",
5
5
  "keywords": [
6
6
  "image-snapshot",
@@ -1,5 +1,5 @@
1
1
  import dedent from 'dedent'
2
- import { afterEach, beforeAll, expect } from 'vitest'
2
+ import { afterEach, beforeAll } from 'vitest'
3
3
  import { toTaskId } from '../client.ts'
4
4
  import { ctx } from '../client/ctx.ts'
5
5
  import { shouldTakeSnapshot } from '../client/should_take_snapshot.ts'
@@ -56,12 +56,13 @@ export function createVis(commands: SetupVisSuiteCommand) {
56
56
  afterEach: {
57
57
  async matchImageSnapshot() {
58
58
  const test = ctx.getCurrentTest()
59
+
59
60
  if ((test?.result?.errors?.length ?? 0) > 0) return
60
61
 
61
62
  const meta = getAutoSnapshotOptions(test)
62
63
  if (!shouldTakeSnapshot(meta)) return
63
64
 
64
- await expect(getSubject(meta?.subjectDataTestId ?? subjectDataTestId)).toMatchImageSnapshot(meta)
65
+ await test!.context.expect(getSubject(meta?.subjectDataTestId ?? subjectDataTestId)).toMatchImageSnapshot(meta)
65
66
  },
66
67
  matchPerTheme(themes: Record<string, () => Promise<void> | void>) {
67
68
  return async function matchImageSnapshot() {
@@ -74,10 +75,12 @@ export function createVis(commands: SetupVisSuiteCommand) {
74
75
  for (const themeId in themes) {
75
76
  try {
76
77
  await new Promise((a) => setTimeout(() => a(themes[themeId]!()), 10))
77
- await expect(getSubject(meta?.subjectDataTestId ?? subjectDataTestId)).toMatchImageSnapshot({
78
- ...meta,
79
- customizeSnapshotId: (id) => `${id}-${themeId}`,
80
- })
78
+ await test!.context
79
+ .expect(getSubject(meta?.subjectDataTestId ?? subjectDataTestId))
80
+ .toMatchImageSnapshot({
81
+ ...meta,
82
+ customizeSnapshotId: (id) => `${id}-${themeId}`,
83
+ })
81
84
  } catch (error) {
82
85
  errors.push([themeId, error])
83
86
  }