vitest-plugin-vis 1.6.3 → 1.6.5
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;;;;;;;
|
|
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;;EA0ClE"}
|
package/esm/setup/create_vis.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import dedent from 'dedent';
|
|
2
|
-
import { afterEach, beforeAll
|
|
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,9 +73,13 @@ 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
|
|
76
|
+
await test.context
|
|
77
|
+
.expect(getSubject(meta?.subjectDataTestId ?? subjectDataTestId))
|
|
78
|
+
.toMatchImageSnapshot({
|
|
77
79
|
...meta,
|
|
78
|
-
customizeSnapshotId:
|
|
80
|
+
customizeSnapshotId: meta?.customizeSnapshotId
|
|
81
|
+
? (id, index) => `${meta.customizeSnapshotId(id, index)}-${themeId}`
|
|
82
|
+
: (id) => `${id}-${themeId}`,
|
|
79
83
|
});
|
|
80
84
|
}
|
|
81
85
|
catch (error) {
|
package/package.json
CHANGED
package/src/setup/create_vis.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import dedent from 'dedent'
|
|
2
|
-
import { afterEach, beforeAll
|
|
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,14 @@ 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
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
await test!.context
|
|
79
|
+
.expect(getSubject(meta?.subjectDataTestId ?? subjectDataTestId))
|
|
80
|
+
.toMatchImageSnapshot({
|
|
81
|
+
...meta,
|
|
82
|
+
customizeSnapshotId: meta?.customizeSnapshotId
|
|
83
|
+
? (id, index) => `${meta.customizeSnapshotId!(id, index)}-${themeId}`
|
|
84
|
+
: (id) => `${id}-${themeId}`,
|
|
85
|
+
})
|
|
81
86
|
} catch (error) {
|
|
82
87
|
errors.push([themeId, error])
|
|
83
88
|
}
|