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

To run Loki screenshot tests in Docker, start your Storybook server, create a baseline with yarn loki update, then compare later captures with yarn loki test. Loki does not launch Storybook for you. Review screenshots and diffs before approving any changed reference.

What you need before running Loki in Docker

  • A Storybook project and Loki installed as a development dependency.
  • Docker available to the account that runs Loki.
  • A Node.js version compatible with your installed Loki and Storybook versions.

Loki’s getting-started documentation, last updated 2024-08-27, lists Node 16+ for its setup. Treat that as historical guidance, not a verified compatibility promise for current releases; check the documentation for the Loki version installed in your project. The same caution applies to Docker image defaults and CLI options. Loki getting started

Install and initialize Loki

  1. From the project directory, install Loki: yarn add loki --dev.
  2. Initialize its configuration: yarn loki init.
  3. Check the generated configuration and confirm that the installed Loki version supports the options you intend to use.

Start Storybook before capture

Start the Storybook server in a separate terminal before running Loki. The project documentation states: “For loki to be able to access your stories you must start the storybook server.” A typical command is yarn storybook; use your project’s actual script if it differs. Loki getting started

If Storybook listens on a non-default port or host, pass the matching values using the CLI’s --port and --host options. Confirm the syntax supported by the Loki and package-manager versions in use. For example, the Loki CLI documentation shows forwarding a port option with yarn loki test -- --port 9009; package managers can differ in how they forward arguments. Loki CLI

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Create baselines and run comparisons

  1. With Storybook running, generate the initial reference screenshots: yarn loki update.
  2. Commit the approved references with the project. Loki’s getting-started guide says Git LFS is optional.
  3. For later visual regression runs, execute yarn loki test.
  4. Inspect both captured screenshots and the generated differences. Only accept a change after confirming it is intentional.
  5. When a UI change is expected, update the reference using yarn loki approve, or use the command Loki suggests to approve only failing stories when that is the intended scope.

The CLI documentation lists these default output directories: references in ./.loki/reference, fresh captures in ./.loki/current, and differences in ./.loki/difference. It also lists pixelmatch, looks-same, and gm as diff engines. These documented defaults may vary by release, so verify them against the installed CLI before depending on a path or engine. Loki CLI

Configure Loki’s Chrome Docker target

Loki documents Chrome in Docker as a supported capture target. Its CLI options let you adjust how the Chrome container runs and how it reaches your Storybook server. The CLI reference was last updated 2024-08-27; check your installed version before copying version-specific values. Loki CLI

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Option What it controls When to consider changing it
--chromeDockerImage Selects the Chrome container image. When the documented or configured image does not suit the installed Loki version or your environment.
--dockerNet Passes a Docker network mode, such as host or bridge. When Chrome in the container cannot reach Storybook using the current network setup. There is no universally correct mode for every CI environment.
--chromeDockerUseCopy Copies local stories instead of using a volume mount. When mounting local files is unavailable or unreliable in the environment.
--dockerWithSudo Invokes Docker with sudo. When the environment requires elevated permissions for Docker commands.

The CLI page lists yukinying/chrome-headless-browser-stable:118.0.5993.117 as a default Chrome Docker image. That is a historical documented value, not a current recommendation. Confirm the right image for your installed Loki version before setting or relying on it. Loki CLI

Pass Docker settings through the package manager

When using Yarn or npm, Loki’s CLI documentation says to put -- before Loki arguments so the package manager forwards them. For example: yarn loki test -- --port 9009. Apply the same forwarding pattern for Docker options if supported by your installed CLI, and check your package manager’s conventions if the arguments are not received as expected. Loki CLI

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Make screenshots stable and repeatable

Control external requests and data

By default, a failed network request from a story fails the test. Avoid depending on live services or changing remote data where possible; provide controlled responses so a temporary outage or content change does not look like a visual regression. Loki configuration

Handle animation and asynchronous rendering

Animation timing can change the captured frame between runs. Loki’s flaky-test guidance documents disabling animations with the chromeEnableAnimations option. For stories that finish rendering asynchronously, use the documented callback pattern to signal completion rather than capturing before the final UI is ready. Loki flaky tests

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Troubleshoot common Docker test failures

Symptom Likely cause What to check
Loki cannot load stories Storybook is not running, or Loki is pointed at the wrong host or port. Start Storybook first, confirm it is reachable, then align Loki’s host and port settings with the server.
Chrome in Docker cannot connect to Storybook The selected Docker network cannot reach the Storybook server. Check the configured host, port, and --dockerNet mode. Test an appropriate network mode for your local or CI environment; the docs do not prescribe one mode for every setup.
Files or stories are unavailable inside the capture environment A volume mount is not working in the environment. Check mount access and consider --chromeDockerUseCopy to copy local stories instead.
Docker exits with a permissions error The runner cannot invoke Docker with its current permissions. Check the runner’s Docker access; use --dockerWithSudo only if that environment requires sudo.
Tests fail after a network request fails The story depends on an unavailable or unstable request. Stub or otherwise control the request and its data for deterministic rendering.
Diffs vary across runs without an intentional UI change Animation timing or unfinished asynchronous rendering may be changing the frame. Disable animations where appropriate and signal completion for asynchronous stories.
Every story shows a difference The reference may be stale, or capture conditions may have changed. Inspect images in ./.loki/reference, ./.loki/current, and ./.loki/difference; verify the environment before approving references.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If you need a clean screenshot without configuring Loki and Docker, ScreenshotNeo offers a one-request screenshot API. The following cURL command captures a page as WebP; see the ScreenshotNeo API documentation for parameters and response details.

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

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

ScreenshotNeo accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status. Its MCP server includes take_screenshot, get_page_info, and capture_pdf for AI agents. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots.

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

Frequently Asked Questions

Does Loki start Storybook automatically?

No. Start the Storybook server before running Loki.

Which command creates the first reference screenshots?

Run yarn loki update while Storybook is available.

Can I use Docker with a different Chrome image?

The CLI documents --chromeDockerImage; check the requirements for your installed Loki version before choosing an image.

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

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.