@lewiswright/storybook-addon-vis
Version:
Storybook Vitest visual testing addon
40 lines (36 loc) • 985 B
text/typescript
import type {
AutoSnapshotOptions,
ComparisonMethod,
FailureThresholdOptions,
ImageSnapshotCompareOptions,
ImageSnapshotIdOptions,
ImageSnapshotTimeoutOptions,
ImageSnapshotAnimationOptions,
PixelComparisonOptions,
SsimComparisonOptions,
ToMatchImageSnapshotOptions,
} from 'vitest-plugin-vis/client'
// This fix the inferred type cannot be named error
export type {
AutoSnapshotOptions,
ComparisonMethod,
ImageSnapshotCompareOptions,
ImageSnapshotIdOptions,
ImageSnapshotTimeoutOptions,
ImageSnapshotAnimationOptions,
ToMatchImageSnapshotOptions,
SsimComparisonOptions,
PixelComparisonOptions,
FailureThresholdOptions,
}
/**
* Define snapshot parameter for auto snapshot.
*/
export function defineAutoSnapshotParam<M extends ComparisonMethod>(
snapshot: ToMatchImageSnapshotOptions<M> & AutoSnapshotOptions,
) {
return { snapshot }
}
export function isSnapshotEnabled(tags: string[]) {
return tags.lastIndexOf('!snapshot') < tags.lastIndexOf('snapshot')
}