MCPcopy
hub / github.com/americanexpress/jest-image-snapshot / runDiffImageToSnapshot

Function runDiffImageToSnapshot

src/diff-snapshot.js:411–435  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

409
410
411function runDiffImageToSnapshot(options) {
412 options.receivedImageBuffer = options.receivedImageBuffer.toString('base64');
413
414 const serializedInput = JSON.stringify(options);
415
416 let result = {};
417
418 const writeDiffProcess = childProcess.spawnSync(
419 process.execPath, [`${__dirname}/diff-process.js`],
420 {
421 input: Buffer.from(serializedInput),
422 stdio: ['pipe', 'inherit', 'inherit', 'pipe'],
423 maxBuffer: options.maxChildProcessBufferSizeInBytes,
424 }
425 );
426
427 if (writeDiffProcess.status === 0) {
428 const output = writeDiffProcess.output[3].toString();
429 result = JSON.parse(output);
430 } else {
431 throw new Error(`Error running image diff: ${(writeDiffProcess.error && writeDiffProcess.error.message) || 'Unknown Error'}`);
432 }
433
434 return result;
435}
436
437module.exports = {
438 diffImageToSnapshot,

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…