<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/our-swiftui-snapshot-tests-passed-locally-but-failed-on-ci-here-s-the-actual-fix--0qsmtdafi" -->

---
title: Our SwiftUI snapshot tests passed locally but failed on...
description: A team running 500+ SwiftUI snapshot tests discovered their tests passed locally but failed on GitHub Actions CI. After ruling out resolution mismatches, font...
canonical: https://daily.dev/posts/our-swiftui-snapshot-tests-passed-locally-but-failed-on-ci-here-s-the-actual-fix--0qsmtdafi
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Our SwiftUI snapshot tests passed locally but failed on CI. Here's the actual fix. | daily.dev
og:description: A team running 500+ SwiftUI snapshot tests discovered their tests passed locally but failed on GitHub Actions CI. After ruling out resolution mismatches, font...
og:url: https://daily.dev/posts/our-swiftui-snapshot-tests-passed-locally-but-failed-on-ci-here-s-the-actual-fix--0qsmtdafi
og:image: https://api.daily.dev/og/posts/0qSmTDaFi.png
og:image:alt: Our SwiftUI snapshot tests passed locally but failed on CI. Here's the actual fix.
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Our SwiftUI snapshot tests passed locally but failed on CI. Here's the actual fix.

**[DEV](https://daily.dev/sources/devto)** · 6 min read · 6 upvotes · 0 comments

## Summary

A team running 500+ SwiftUI snapshot tests discovered their tests passed locally but failed on GitHub Actions CI. After ruling out resolution mismatches, font rendering differences, and non-deterministic animations, they found the root cause: swift-snapshot-testing renders views inside an NSWindow, and the title bar height differs between physical Macs and headless CI VMs, causing images to be 167 pixels shorter on CI. The fix was to bypass NSWindow entirely and render directly to an NSHostingView using cacheDisplay(in:to:), eliminating the environment-dependent offset. As a bonus, they also migrated from iOS Simulator to macOS for testing, cutting local test time from 170s to 7s and CI time from ~30 to ~17 minutes. Key diagnostic tip: use sips to compare pixel dimensions of reference vs failure images before tuning precision thresholds.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://dev.to/d4g4/our-swiftui-snapshot-tests-passed-locally-but-failed-on-ci-heres-the-actual-fix-5fhd>

## Similar posts on daily.dev

- [Snapshot Testing on iOS: A Setup That Actually Stays Green](https://daily.dev/posts/snapshot-testing-on-ios-a-setup-that-actually-stays-green-wxncwpy3s) · Medium · 0 upvotes · 0 comments
- [Solving SwiftUI Pain Points and Performance Bottlenecks](https://daily.dev/posts/solving-swiftui-pain-points-and-performance-bottlenecks-c8d7n01t1) · Fatbobman · 0 upvotes · 0 comments
- [SwiftUI Performance: Find Redraws in Xcode Instruments](https://daily.dev/posts/swiftui-performance-find-redraws-in-xcode-instruments-ybsyckv3q) · SwiftLee · 1 upvotes · 0 comments

---

Tags: [#testing](https://daily.dev/tags/testing), [#ios](https://daily.dev/tags/ios), [#cicd](https://daily.dev/tags/cicd), [#swift](https://daily.dev/tags/swift), [#swiftui](https://daily.dev/tags/swiftui)

[View this post on daily.dev](https://daily.dev/posts/our-swiftui-snapshot-tests-passed-locally-but-failed-on-ci-here-s-the-actual-fix--0qsmtdafi)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Our SwiftUI snapshot tests passed locally but failed on CI. Here's the actual fix.","url":"https://daily.dev/posts/our-swiftui-snapshot-tests-passed-locally-but-failed-on-ci-here-s-the-actual-fix--0qsmtdafi","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/our-swiftui-snapshot-tests-passed-locally-but-failed-on-ci-here-s-the-actual-fix--0qsmtdafi"},"datePublished":"2026-04-16T20:16:09.395Z","dateModified":"2026-04-16T20:16:34.068Z","description":"A team running 500+ SwiftUI snapshot tests discovered their tests passed locally but failed on GitHub Actions CI. After ruling out resolution mismatches, font...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/7d4a5938528b70c08874ea64cf4a4611?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/7d4a5938528b70c08874ea64cf4a4611?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"DEV","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"DEV","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/devto","url":"https://daily.dev/sources/devto"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/our-swiftui-snapshot-tests-passed-locally-but-failed-on-ci-here-s-the-actual-fix--0qsmtdafi","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":6},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"testing,ios,cicd,swift,swiftui","timeRequired":"PT6M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"DEV","item":"https://daily.dev/sources/devto"},{"@type":"ListItem","position":3,"name":"Our SwiftUI snapshot tests passed locally but failed on CI. Here's the actual fix."}]}
```

