October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk6 min

How to Use Loki for Visual Regression Testing in React

Loki compares screenshots of Storybook stories with approved baselines. Learn how to initialize it, run local and CI tests, review diffs, and update references safely.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Loki tests React interfaces by capturing Storybook stories and comparing them with approved reference screenshots. Add it to your project, start Storybook separately, create a baseline with yarn loki update, and use yarn loki test to catch later visual changes. Review every difference before approving it: an image diff can show an intentional redesign or an unintended regression, and does not replace unit, behavior, or accessibility tests.

What Loki tests—and what it does not

Loki runs visual comparisons against your Storybook stories. Each story should represent a meaningful UI state—such as a default button, an error message, or a populated form—that you want to check for appearance changes. Loki captures the rendered stories and compares the images with reference screenshots you have saved.

This workflow detects visual differences; it does not establish that a component behaves correctly, is accessible, or passes unit tests. Keep those checks in your broader test suite.

Install Loki and initialize the project

The Loki getting-started guide lists Node 16+ and uses Yarn in its examples. Its setup and compatibility notes were last updated in 2024, so treat them as documentation guidance rather than a guarantee for every current Loki, Storybook, Node, or browser combination. Check the requirements for the Loki version and CI image you actually use.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
  1. From the project root, add Loki as a development dependency: yarn add loki --dev.
  2. Initialize its configuration: yarn loki init. The initializer detects the project and writes a default configuration.
  3. Review the generated browser target, dimensions, and other settings before relying on the defaults. Loki documents targets for Chrome in Docker, Chrome in AWS Lambda, local Chrome, and iOS and Android simulators or emulators. The README recommends Chrome in Docker; the available target can depend on your setup.

Documented prerequisites vary by target: the guide lists GraphicsMagick as optional for the gm diff engine, Docker for chrome.docker, and Chrome 59+ for chrome.app. Because these notes are dated, verify them against your installed Loki version and execution environment.

Run the baseline-and-review workflow

Start Storybook yourself

Start the Storybook app using your project’s existing script, for example yarn storybook if that script is configured. Loki does not start Storybook or a simulator for you; its README explicitly says to ensure Storybook and any simulator or emulator are running before tests. Keep this server running while you execute Loki.

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors

Create the initial reference screenshots

With Storybook available, run yarn loki update. This creates the reference images that future test runs will use. Review the resulting files and commit them to version control so the baseline is intentional and changes can be reviewed alongside the UI changes. The Loki guide says Git LFS can be used optionally for storing references.

Compare after a UI or story change

After changing a component or story, run yarn loki test. Loki captures the stories again, compares the images with the references, and writes current captures and visual differences to its output folders. Use the configured output directories to find the artifacts; the CLI reference documents separate locations for reference images, current output, and difference images.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.

Inspect and approve deliberately

Open each diff image and decide whether the change is expected. If it is, approve the new image with yarn loki approve, or use the command Loki suggests to update only failed tests. Commit approved reference changes with the implementation. Do not update baselines automatically just to make a failing run green: that can conceal an unintended change.

Configure targets and comparisons

Loki’s settings let you choose how Storybook is reached, where images are stored, and how image differences are calculated. Check the generated configuration and Loki CLI reference for option names supported by your installed version.

Rank #4
Sale
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient
  • Storybook address and ports: use the configured Storybook URI and ports to point Loki at the server or static build you intend to test.
  • Browser or device target: choose among the documented local, containerized, Lambda, iOS simulator, and Android emulator options according to the environment you can reliably run.
  • Image directories: identify the reference-image, current-capture, and difference-image directories so reviewers can inspect the right artifacts.
  • Diff engine: the CLI reference lists pixelmatch, looks-same, and gm. The getting-started guide identifies GraphicsMagick as optional for gm.
  • Named configurations: the getting-started guide describes selecting configurations by regex; for example, a name containing laptop can be targeted with a matching expression. Confirm exact CLI/config syntax for your Loki version.

When tuning a target, keep the conditions consistent between baseline and test runs: browser, viewport or device, Storybook content, and runtime environment all affect the rendered image. A difference is useful only when it reflects a meaningful change rather than an accidental mismatch in capture setup.

Run Loki in CI with a static Storybook

The official Loki CI guide documents a static-build pattern: build Storybook, then point Loki to the generated directory and require a reference for every tested story. Adapt the build command and output path to your package scripts.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
  1. Build Storybook using the project’s configured build script.
  2. Run Loki against the resulting static directory: yarn loki test --requireReference --reactUri file:./storybook-static.
  3. Keep approved reference images under version control so CI checks changes against an intentional baseline.

--requireReference makes CI fail when a story has no baseline. That is useful because CI should report missing coverage or unexpected changes—not create or approve reference images automatically. Ensure the path after file: matches the actual static output location in your workflow.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common failures and practical fixes

  • Loki cannot connect to Storybook: start the Storybook server before running Loki, or use the static Storybook path in CI. Check that the URI and port in the Loki configuration match the server you started.
  • A simulator or emulator target fails: launch the required simulator or emulator separately before the Loki command; Loki does not start it for you.
  • CI reports a missing reference: with --requireReference, this means a tested story has no committed baseline. Run the baseline workflow deliberately, review the image, and commit the approved reference.
  • A test reports visual differences: inspect the current capture and diff image. If the UI change is intended, approve the new reference; otherwise fix the UI or the inconsistency in the capture environment.
  • The gm diff engine cannot run: check whether GraphicsMagick is installed and available in the environment, since the guide lists it as an optional prerequisite for that engine.
  • Documented browser or Node versions do not fit the project: the cited setup guide’s version notes are from 2024, not a current compatibility matrix. Verify requirements against the Loki version, browser target, and CI image actually in use rather than assuming old version statements guarantee compatibility.

Performance, reliability, and baseline maintenance

Loki’s documented workflow depends on a running Storybook or a built static Storybook plus the selected browser or device target. The sources do not establish a universal run time or performance benchmark, so measure it in your own CI environment. For a dependable comparison, use repeatable capture conditions and keep baseline updates reviewable; investigate whether a change is in the UI or environment before approving it.

The project documentation describes repository-based reference images and optional Git LFS storage. That keeps baseline changes tied to code review, but teams should account for the storage and review process their own story set requires. Loki’s documentation does not provide a complete current feature-by-feature comparison with hosted visual-review services.

Or skip the browser setup

Loki is designed for Storybook-based visual regression; for a one-off website capture or an agent-driven screenshot task, ScreenshotNeo is a separate screenshot API and MCP server. Its API returns a screenshot or PDF from one GET request. For example, save this cURL call as shot.webp:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for parameters and setup. Cookie banners and consent notices, newsletter popups, and chat widgets are removed before capture; bot checks, blank pages, failed loads, timeouts, and cache hits are not billed. Its MCP server provides screenshot tools for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Sign up for ScreenshotNeo free.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.