@lewiswright/vitest-plugin-vis
Version:
Vitest visual testing plugin
11 lines (10 loc) • 375 B
JavaScript
export function convertThresholdUnit({ failureThresholdType, width, height }, pixelDiff) {
switch (failureThresholdType) {
case 'pixel':
return pixelDiff;
case 'percent':
return (pixelDiff / (width * height)) * 100;
default:
throw new Error(`Unsupported failureThresholdType: ${failureThresholdType}`);
}
}