{"library":"reg-cli","title":"reg-cli: Visual Regression Test Tool","description":"reg-cli is a command-line interface (CLI) tool for performing visual regression testing on images and generating a comprehensive, interactive HTML report. It helps developers detect unintended visual changes in user interfaces over time by comparing 'actual' images with 'expected' baseline images. The current stable version is 0.18.14, with development actively focused on minor feature enhancements to the report UI, dependency updates, and security patches. Key differentiators include its flexible image comparison logic with adjustable thresholds, support for parallel processing, and the ability to generate reports from pre-existing JSON data. It requires Node.js v18 or newer for execution, ensuring compatibility with modern JavaScript environments. It is primarily used via its CLI but also exposes a programmatic API for integration into custom build workflows.","language":"javascript","status":"active","last_verified":"Wed Apr 22","install":{"commands":["npm install reg-cli"],"cli":{"name":"reg-cli","version":null}},"imports":["import RegCli from 'reg-cli';","import type { RegCliOptions } from 'reg-cli';","import type { RegResult } from 'reg-cli';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { spawn } from 'node:child_process';\nimport { mkdir, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\n\nconst actualDir = './screenshots/actual';\nconst expectedDir = './screenshots/expected';\nconst diffDir = './screenshots/diff';\nconst reportPath = './reg-report/index.html';\n\nasync function setupDirs() {\n  await mkdir(actualDir, { recursive: true });\n  await mkdir(expectedDir, { recursive: true });\n  await mkdir(diffDir, { recursive: true });\n  // Simulate creating a dummy actual image\n  await writeFile(join(actualDir, 'test.png'), Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=', 'base64'));\n  // Simulate creating a dummy expected image for comparison\n  await writeFile(join(expectedDir, 'test.png'), Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=', 'base64'));\n}\n\nasync function runRegCli() {\n  await setupDirs();\n\n  const args = [\n    actualDir,\n    expectedDir,\n    diffDir,\n    '-R', reportPath,\n    '--matchingThreshold', '0.01',\n    '--thresholdRate', '0.001'\n  ];\n\n  const regCliProcess = spawn('npx', ['reg-cli', ...args], { stdio: 'inherit' });\n\n  regCliProcess.on('close', (code) => {\n    if (code === 0) {\n      console.log('reg-cli comparison completed successfully. Check report at', reportPath);\n    } else {\n      console.error(`reg-cli exited with code ${code}. Visual differences might have been found.`);\n    }\n  });\n}\n\nrunRegCli().catch(console.error);\n","lang":"typescript","description":"This quickstart demonstrates how to run `reg-cli` from a Node.js script to compare images, generate a diff, and output an HTML report. It sets up dummy directories and files, then executes the CLI command with common options.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}