October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober 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

Chromatic Tests Fail When Fonts Load Too Late: How to Fix Them

Late-loading web fonts can change text metrics after Chromatic begins capturing a story. Find the failed font request, preload the exact face, and synchronize interactions when necessary.

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.

If a Chromatic snapshot or interaction test captures a story before its custom font is ready, the browser may render text in a fallback font first. Different text dimensions can shift elements and create visual diffs or inconsistent results. Start by checking the failed font URL, then preload the exact font in Storybook; serve it locally or explicitly wait for it when needed.

Why late fonts make Chromatic tests fail

Browsers may fetch a custom font only when page content first needs it. Until the font arrives, text can use a fallback face; when the custom font loads, the browser lays out the text again. Changes in glyph widths, line breaks, and element dimensions can alter positions that a snapshot or interaction test observes.

As an Amazon Associate I earn from qualifying purchases.

Chromatic says it waits for resources such as fonts before capturing a snapshot, but external resources can still fail or arrive late, and asynchronous rendering can make later resources difficult to detect reliably. Its resource-loading documentation describes 15 seconds to render a story and an additional 15 seconds for interaction tests; those are documented timing limits, not a guarantee that a slow or unreachable font will be ready. Chromatic may retry when resources do not arrive in time. See Chromatic’s resource-loading guidance and unstable-test debugging.

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

As Chromatic puts it, “Chromatic waits for resources like images and fonts to load before capturing a snapshot.” The practical distinction is that a wait cannot make an unavailable or persistently slow external font dependable.

Diagnose the specific font request first

  1. Open the failed build’s resource warning or unstable-test trace and identify the font URL.
  2. Run Storybook and verify that the URL is valid and the font file actually loads in the browser.
  3. Check whether the test browser can reach the host. External CDN access, network restrictions, or firewall rules can make a font available locally but unavailable to the test.
  4. Confirm that the font URL in the preload matches the face and file your CSS requests, including the correct weight and style variant.

Chromatic’s resource-loading documentation explains how resource warnings can help locate the problem.

Preload the font in Storybook

Chromatic’s preferred fix is to preload the precise font file from Storybook’s .storybook/preview-head.html. Use the actual file URL, font format, and cross-origin setting appropriate to your asset:

<link
  rel="preload"
  href="/fonts/your-font.woff2"
  as="font"
  type="font/woff2"
  crossorigin="anonymous"
>

Replace /fonts/your-font.woff2 with the URL used by your stylesheet. A preload for the wrong weight, file, or URL will not ensure that the requested face is ready. For details and Chromatic’s Storybook configuration guidance, see Font loading in Chromatic and the Chromatic for Storybook quickstart.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
Font. The SourceBook
  • Used Book in Good Condition

Make font delivery deterministic

If the font comes from an external host, consider placing the test font files in Storybook’s static directory and pointing the test stylesheet at those local assets. This avoids depending on an external network request during capture while preserving the intended typeface. Production can keep its separate delivery arrangement if that better fits deployment needs.

Local hosting does not remove the need to use the correct font URL or ensure the asset is included in the Storybook build. Verify the request in the browser and in Chromatic’s failure details.

Wait explicitly when a story needs a font

For a story that must not proceed until a face is ready, Storybook’s global loader can use the browser Font Loading API. Load a specific face when you know which one the story needs:

export const loadFonts = async () => {
  await document.fonts.load('400 1em Font Name');
};

export const globalTypes = {};

export const loaders = [loadFonts];

Adapt this to the Storybook version and configuration already used by your project; the important part is awaiting the font request before the story is captured. Chromatic’s font-loading documentation shows how to gate its loader for Chromatic with isChromatic().

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

Alternatively, await document.fonts.ready to wait until fonts used by the document have loaded and layout operations are complete:

await document.fonts.ready;

This promise does not load every face merely declared in CSS: it resolves after fonts used by the page have completed loading and associated layout work. For the browser API’s exact behavior, consult MDN’s documentation on FontFaceSet.ready, Document.fonts, and the CSS Font Loading API.

Prevent interaction tests from starting too early

Chromatic interaction tests run as soon as the DOM loads. A play function can therefore begin while an external font is still in flight, depending on network timing. Preloading in the document head is preferable because it starts the request early. If you cannot preload, await the required font before the interaction depends on text dimensions. A fixed delay is a weaker fallback: it may be unnecessarily slow on a fast run and still too short on a slow one. See Chromatic’s interaction-test guidance.

Choose a fallback or disable custom fonts only deliberately

Keep a suitable CSS fallback

A fallback font helps keep text legible if the custom face is unavailable. It may not have matching metrics, so it is resilience rather than a synchronization fix. Chromatic lists Arial, Verdana, and Trebuchet MS as sans-serif examples; Georgia and Times New Roman for serif; and Courier New or Courier for monospace. Choose a stack that covers the languages your UI displays. See Chromatic’s font-loading guidance.

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

Use font-display: optional only if fallback rendering is acceptable

Chromatic documents font-display: optional as an option for its environment. It can avoid waiting for a custom face, but the snapshot may then show the fallback appearance. Use it only when that is acceptable for the visual test, not as a way to verify the custom typography.

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

Pick the remedy that fits the failure

Remedy Reliability and fidelity Trade-off
Local static font plus preload Reduces external network dependence while retaining the intended typeface. Requires maintaining the local asset and matching preload URL to the requested face.
Font Loading API wait Explicitly synchronizes a story with the needed face or used page fonts. The relevant face must be requested; waiting for document.fonts.ready does not load unused declarations.
Web-safe fallback Provides a resilient alternative if the custom font cannot load. Different font metrics can still change layout and visual results.
font-display: optional Can avoid dependency on the custom font in Chromatic. May render the fallback instead of the intended typography.
Fixed delay May give an external request extra time in a particular run. Timing-dependent; not a dependable substitute for preload or explicit readiness.

Troubleshoot common symptoms

  • The font request is 404 or absent: Correct the asset path and ensure the font is included in Storybook’s static output.
  • The request works locally but fails in Chromatic: Check test-browser access to the external host and network restrictions; consider serving the test asset locally.
  • The preload appears to have no effect: Verify that its URL, format, weight, and style correspond to the face requested in CSS.
  • The snapshot still has shifted text: Ensure the story actually requests the face, and wait for that face before capture or interaction rather than relying on an unused font declaration.
  • Only interaction tests are unstable: The interaction may start before an external font arrives. Start the font request earlier with preload and synchronize before text-dependent actions.
  • A delay fixes some runs but not others: Replace the timing guess with local delivery, preload, or an explicit Font Loading API wait.
  • Fallback rendering is consistent but visually wrong: Remove the optional-font workaround if typography is under test, and make the intended font available before capture.

Or skip the browser setup

If your goal is a website screenshot rather than a Chromatic component test, ScreenshotNeo can return a screenshot or PDF from one GET request. For example, this cURL request captures 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. Cookie banners, newsletter popups, and chat widgets are removed before capture, with each cleanup step configurable. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed; response headers report the page verdict and billing status. Its MCP server lets AI agents use take_screenshot, get_page_info, and capture_pdf. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for free.

Frequently Asked Questions

Does waiting for document.fonts.ready load every font declared in CSS?

No. It resolves after fonts used by the document have loaded and layout operations have completed; unused declared faces need not load.

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

Should I use a longer fixed delay to fix late-font failures?

A delay depends on network timing and can remain too short on a slow run. Preload the needed font or explicitly await it instead.

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. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair 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.