UNPKG

storybook-addon-vis-v9-fix-test

Version:
37 lines (33 loc) 1.15 kB
import { expect } from 'storybook/test'; import { success, matchImageSnapshotAction, toTaskId } from 'vitest-plugin-vis/client-api'; // src/client/vitest_proxy.ts var browserContext; var vitestSuite; if (globalThis.__vitest_browser__) { import('@vitest/browser/context').then((m) => { browserContext = m; }); import('vitest/suite').then((m) => { vitestSuite = m; }); } var commands = new Proxy({}, { get(_target, prop) { return browserContext?.commands?.[prop]; } }); var getCurrentTest = () => vitestSuite?.getCurrentTest(); function toMatchImageSnapshot(subject, options) { const test = getCurrentTest(); if (!test) return Promise.resolve(success); return matchImageSnapshotAction(commands, toTaskId(test), subject, options).then(() => success); } // src/client/storybook/expect_extend.ts expect.extend({ toMatchImageSnapshot }); // src/client/storybook/tags.ts function isSnapshotEnabled(tags) { return tags.lastIndexOf("!snapshot") < tags.lastIndexOf("snapshot"); } export { commands, getCurrentTest, isSnapshotEnabled }; //# sourceMappingURL=chunk-YYPWZMMD.js.map //# sourceMappingURL=chunk-YYPWZMMD.js.map