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

Build Storybook, run Loki against that build with --requireReference, and let CI fail when a screenshot is missing or differs from its approved baseline. The critical setup is to commit reviewed reference images and use a renderer your CI runner can reproduce.

What a Loki CI job needs

Loki tests Storybook stories by capturing screenshots and comparing them with reference images. A useful pipeline therefore needs a build or server that Loki can load, an available rendering target, and approved baselines in the repository. In CI, use --requireReference so a story without a baseline fails instead of silently becoming a new reference.

The Loki documentation’s representative static-build workflow is:

build-storybook && loki --requireReference --reactUri file:./storybook-static

This uses the built Storybook directory as Loki’s input. The documented CI workflow does not generally require Storybook server mode. Adapt the build command and directory to your project rather than assuming every Storybook setup writes to storybook-static. See the Loki continuous-integration guide.

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

Install Loki and initialize configuration

  1. From your project root, install Loki as a development dependency: yarn add loki --dev.

  2. Initialize its configuration: yarn loki init. Loki detects the project type and writes a default loki configuration in package.json.

  3. Review the generated configuration. Keep only a renderer and settings that match your project and CI environment.

Loki’s getting-started documentation, last updated 2024-08-27, specifies Node 16+ and notes that GraphicsMagick or Docker may be needed depending on the selected diff engine or renderer. Those are documentation-era requirements, not a compatibility guarantee for every current Loki release; check the versions pinned by your project. See Loki getting started.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
HP ProLiant DL360 G7 1U RackMount 64-bit Server - Dual 6-Core X5675 Xeon 3.06GHz CPUs - 72GB PC3-10600R RAM - 4x900GB 10K SAS SFF HDD - P410i RAID, 4xGigaBit NIC - 2 PSU (Renewed)
  • HP ProLiant DL360 G7 Business Server, the perfect enterprise server or small business server!
  • Processors: Dual (2) Xeon X5675 6-Core 3.06 GHz 12MB CPUs Max Turbo 3.46 GHz
  • Memory: 72GB (4 x 16GB) DDR3 PC3-10600R Memory; Storage: 3.6TB (4 x 900GB) 10K 12Gb/s SAS 2.5" HDDs
  • Power: Redundant Power Supplies; RAID: HP Smart Array P410i-a 12Gb/s with 4×GigaBit NIC
  • Hard drives and memory upgrades included separately NOT installed, installation required.

Create and commit approved reference images

Generate the initial screenshots intentionally with:

yarn loki update

Inspect the captured images and differences before accepting them. Commit approved references with the code so CI can compare future captures against the same reviewed baseline. The getting-started guide describes a loki folder and says references should be checked into Git; Git LFS is optional if your team wants to store the image files there.

The CLI reference lists default paths as ./.loki/reference for references, ./.loki/current for current captures, and ./.loki/difference for diffs. Configuration and Loki version can affect paths, so check the repository’s actual settings. See the Loki CLI reference.

Add the visual test to your CI command

After the baselines are committed, run the static Storybook build and Loki comparison in sequence. For example, add this script to package.json:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
{
  "scripts": {
    "test:visual": "build-storybook && loki --requireReference --reactUri file:./storybook-static"
  }
}

This is an adaptation of Loki’s documented command, not a universal script name or output path. Run yarn test:visual or npm run test:visual in the CI job, using the package manager and lockfile already adopted by the project. If passing Loki flags through Yarn or npm directly, the CLI documentation notes that an argument separator such as -- may be needed so the package manager forwards them to Loki.

Keep the CI run in comparison mode: do not add loki update to the normal pipeline. Updating baselines is an approval action for an intentional visual change, not a way to make a failing check pass automatically.

Choose a renderer your runner can reproduce

Loki documents Chrome in Docker, local Chrome, iOS simulator, and Android emulator renderers. Its configuration reference includes targets such as chrome.docker, chrome.app, ios.simulator, and android.emulator. Choose based on the platform coverage the team needs and what the CI runner can reliably provide; the documentation does not establish one universally best target.

  • Browser coverage: use a Chrome target when browser rendering is the required comparison; select simulator or emulator targets when the visual output must represent those platforms.
  • Reproducibility: prefer a setup developers and CI can configure consistently, and avoid changing renderer versions without reviewing resulting image changes.
  • Runner burden: make sure the runner has the required browser, Docker, simulator, or emulator support for the chosen target.

Loki configuration also documents viewport dimensions, presets, device settings, selectors, and diff-engine choices. The exact supported options are version-sensitive; consult the configuration reference for the pinned version.

Free tools Windows power users keep installed

One-click scans. No signup required.

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

Make captures stable and reviewable

Visual comparisons can fail because of real UI changes or nondeterministic rendering. Loki’s flakiness guide says it disables common CSS transitions and requestAnimationFrame behavior by default, but identifies looping requestAnimationFrame, GIFs, SVG animations, and React Native Animated as limitations.

  • Unneeded story: mark it to skip with loki: { skip: true } when it should not be part of visual testing.
  • Asynchronous story: use Loki’s @loki/create-async-callback pattern when capture must wait for an explicit completion signal.
  • Animation-driven difference: investigate ongoing animation or timing rather than approving a baseline immediately.

For noisy or large runs, the CLI documents --verboseRenderer for renderer logs and --configurationFilter and --targetFilter for narrowing a run. Check these flags against your installed Loki CLI before relying on them. See Loki’s guidance on flaky tests and the CLI reference.

Review failures and approve intentional changes

A failing comparison means the current render differs from its reference, or a required reference is missing. Inspect the current capture and difference output before deciding what to do. If the visual change is expected, update references in a deliberate review workflow and commit the approved images. Loki’s CLI also documents an approve command that can accept generated references, with --diffOnly to limit approval to failed tests; verify the behavior for your installed version.

If a reference is missing, create it through the baseline update and review process, then commit it. Do not remove --requireReference simply to make CI green: that option is what distinguishes a missing baseline from an accepted comparison.

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.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common CI failures

  • Storybook directory cannot be loaded: confirm the build completed successfully, the directory exists, and the value after --reactUri file: matches the actual output location.
  • CI reports a missing reference: add and review the baseline locally or in an approved workflow, then commit it to the path Loki is using.
  • Many screenshots differ only in CI: check that local and CI use compatible Loki versions, renderer targets, viewport or device settings, and relevant dependencies. The official docs do not provide a universal compatibility matrix.
  • Capture is inconsistent around asynchronous content: provide an explicit completion signal with Loki’s async callback pattern where needed, and inspect animations that continue beyond the common transition handling.
  • Package manager appears to ignore a flag: use the package manager’s argument separator as required by its syntax, then verify the actual Loki command in CI logs.
  • Runner cannot start the renderer: check that the selected browser, Docker engine, simulator, or emulator is available and configured on that runner.

Scale rendering only when the default runner is not enough

For very large suites, Loki documents AWS Lambda as an optional remote-rendering path. The documented setup requires creating a renderer Lambda and making the Storybook build remotely accessible; S3 and HTTPS are given as an approach. This adds AWS deployment and access configuration, so it is not necessary for a basic CI pipeline. The Lambda guidance was last updated 2024-08-27; verify runtime and packaging details against current AWS support before using it. See Loki’s serverless guide.

Or skip the browser setup

Loki is for Storybook visual regression tests. If the task instead is capturing a website screenshot from a URL, ScreenshotNeo provides a one-request API; it is not a replacement for Loki’s story-baseline workflow. For example, save a screenshot of a page as WebP:

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 request options. ScreenshotNeo accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; those steps can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and response headers report the page verdict and billing status. Its MCP server offers screenshot and PDF tools for AI agents. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.

Sign up for ScreenshotNeo’s free plan to try it with 1,000 screenshots a month and no card.

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

Frequently Asked Questions

Does Loki need a running Storybook server in CI?

Not for the documented static-build workflow: Loki can load the built Storybook through a file URI.

Should CI create or update reference screenshots automatically?

No. Keep baseline generation and approval deliberate; the CI comparison should fail for missing references or unapproved differences.

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.