Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'Image must be a base-64 byte array or a filename');
if (golden_image_name instanceof String ||
typeof golden_image_name === 'string') {
if (!path.isAbsolute(golden_image_name)) {
golden_image_name =
path.join(reporter.golden_img_dir, golden_image_name);
}
} else {
chai.assert(
golden_image_name instanceof Uint8Array ||
golden_image_name instanceof TRenderResult ||
golden_image_name instanceof PNG,
`Image to match must be a ${String.name} path, ${
Uint8Array.name} buffer, ${TRenderResult.name}, or a ${
PNG.name}. It is of type ${typeof golden_image_name}.`);
}
const fileprefix = crypto.randomBytes(5).toString('hex');
const src = readImage(image);
const dst = readImage(golden_image_name);
src.filename =
path.join(image_dir, fileprefix + '-src.' + src.format.toLowerCase());
copyImage(image, src.filename);
dst.filename =
path.join(image_dir, fileprefix + '-dst.' + dst.format.toLowerCase());
copyImage(golden_image_name, dst.filename);
const diff_file = path.join(
image_dir, fileprefix + '-diff.' + src.format.toLowerCase());