UNPKG

@lewiswright/storybook-addon-vis

Version:
51 lines (45 loc) 1.57 kB
import { getCurrentTest, commands } from './chunk-KMYH24SZ.js'; import { expect } from '@storybook/test'; import { success, imageSnapshotMatcher, toTaskId } from 'vitest-plugin-vis/client'; export * from 'vitest-plugin-vis'; function toMatchImageSnapshot(subject, options) { const test = getCurrentTest(); if (!test) return Promise.resolve(success); return imageSnapshotMatcher(commands)(test, subject, options).then(() => success); } // src/client/storybook/expect_extend.ts expect.extend({ toMatchImageSnapshot }); // src/client/storybook/param.ts function defineAutoSnapshotParam(snapshot) { return { snapshot }; } function isSnapshotEnabled(tags) { return tags.lastIndexOf("!snapshot") < tags.lastIndexOf("snapshot"); } // src/client/ctx.ts var ctx = { getCurrentTest, __test__reset() { ctx.getCurrentTest = getCurrentTest; } }; // src/client/has_image_snapshot.ts function hasImageSnapshot(options) { const test = ctx.getCurrentTest(); if (!test) return false; const taskId = toTaskId(test); const isAutoSnapshot = !!test.meta.vis?.isAutoSnapshot; if (options?.customizeSnapshotId) { return commands.imageSnapshotNextIndex(taskId).then( (index) => commands.hasImageSnapshot( taskId, options.customizeSnapshotId({ id: taskId, index, isAutoSnapshot }), isAutoSnapshot ) ); } return commands.hasImageSnapshot(taskId, void 0, isAutoSnapshot); } export { defineAutoSnapshotParam, hasImageSnapshot, isSnapshotEnabled }; //# sourceMappingURL=index.js.map //# sourceMappingURL=index.js.map