bruniai
v0.1.24
Published
AI-powered visual regression testing tool - core comparison library
Readme
bruniai
AI-powered visual regression testing tool - core comparison library.
This package provides the core comparison functionality for visual regression testing. It can be used standalone or as a dependency for building custom integrations (e.g., MCP servers, Next.js apps, etc.).
Installation
npm install bruniaiUsage
import { compareImageToUrl, compareUrls } from "bruniai";
const result = await compareUrls({
baseUrl: "https://example.com",
previewUrl: "https://preview.example.com",
page: "/contact",
});
console.log(result.status); // "pass" | "fail" | "warning"
console.log(result.visual_analysis);
console.log(result.images.base_screenshot);
const imageResult = await compareImageToUrl({
baseImageSource: "https://example.com/design.png",
previewUrl: "https://preview.example.com",
page: "/contact",
});
console.log(imageResult.status);API
compareUrls(input: CompareUrlsInput): Promise<CompareUrlsOutput>
Performs a visual comparison between two URLs.
Parameters:
baseUrl(string): Base/reference URL to compare againstpreviewUrl(string): Preview/changed URL to analyzepage(string, optional): Page path to compare (default: "/")prNumber(string, optional): PR number for metadatarepository(string, optional): Repository name for metadata
Returns:
status: Overall comparison status ("pass" | "fail" | "warning" | "none")visual_analysis: Detailed visual analysis result from AIsections_analysis: Formatted sections analysis textimages: Object containing paths to generated screenshots and diff images
compareImageToUrl(input: CompareImageToUrlInput): Promise<CompareImageToUrlOutput>
Performs a visual comparison between a base image source and a preview URL.
Parameters:
baseImageSource(string): Base/reference image source as an HTTP(S) image URL ordata:image/...previewUrl(string): Preview/changed webpage URL to analyzepage(string, optional): Page path to compare on the preview URL (default: "/")prNumber(string, optional): PR number for metadatarepository(string, optional): Repository name for metadata
Returns:
status: Overall comparison status ("pass" | "fail" | "warning" | "none")visual_analysis: Detailed visual analysis result from AIsections_analysis: Formatted sections analysis textimages: Object containing paths to normalized screenshots and diff images
Requirements
- Node.js 18+
- OpenAI API key (set as
OPENAI_API_KEYenvironment variable)
Development
Building
First, build the parent package to generate the dist files:
cd ../..
npm run buildThen build this package:
npm run buildLicense
MIT
