UI parity testing
Deterministic proof that one Octane app renders the same on web, macOS and iOS.
The same .tsrx app must look identical on every target. Two test layers check this automatically, with no model calls:
| Layer | What it compares | Where | Command |
|---|---|---|---|
| 1. Headless parity | WebKit (dist/web) vs OctapusCore (dist/mac, the code AppKit and UIKit draw with): element rects and pixels at 3x | tests/parity, tools/oct-snap | pnpm test:parity |
| 2. e2e flows | Real targets: web (Playwright WebKit) and the iOS brownfield app on a simulator, driven by locators; per-target screenshot baselines, then web vs iOS | tests/e2e | pnpm test:e2e |
Layer 1 is the precise, CI-able check. Layer 2 proves the shipped apps behave the same (tap → state → pixels) and catches host-level regressions.
Layer 1: headless parity
examples/app ── oct build ─┬─ dist/web ── Playwright WebKit ── web.json + web.png
└─ dist/mac ── oct-snap ─────────── native.json + native.png
│
Hermes first commit → HostTree → OctapusDocument (CSS + layout + text)
→ OctapusPainter per node → CGBitmapContext (sRGB, y-down, scale)tools/oct-snap(SwiftPM, depends on the root package) runsapp.hbconce (OctapusBaker.firstCommit), lays the first commit out withOctapusDocumentat a viewport and color scheme, and paints every node withOctapusPainterinto an offscreen bitmap. It doesn't use a window or views. Buttons and inputs are painted as their CSS boxes, which is what the renderers draw. It writes every rendered node (element path such as0/2/1, tag, role, document-space rect) and a PNG of the whole document. Two runs must produce identical bytes, and the runner checks this on every case.- Web (
tests/parity/lib/web-snap.mjs) servesdist/web, opens it in Playwright WebKit (the engine behind Safari and WKWebView) at the same viewport, device scale andprefers-color-scheme, disables transitions, waits fordocument.fonts.readyplus two frames with identical geometry, then writes the same JSON (same element-path walker as the dev tool'sWebPreview) and a full-page PNG. - Compare (
tests/parity/lib/compare.mjs) checks the following:- Rects. Every native node must exist on the web at the same element path with the same tag and an x/y/width/height within 0.5 px. A web element with a box that native doesn't draw fails unless it is inline content of a native text, SVG or button node. The document size must match within 1 px.
- Pixels. A device pixel differs when an RGB channel differs by more than 12/255, unless it is a tolerated edge. A pixel is a tolerated edge when a pixel within 1 device px in the other image matches it (glyph antialiasing, sub-pixel edges), or when the 3×3 box-averaged colors match (the same ink distributed differently, such as fractional vs pixel-snapped borders). Flat areas are never tolerated, so a wrong color always counts. The case fails if more than 0.1 % of pixels differ, or more than 4 % of any 32×32 CSS px tile.
- A diff PNG paints tolerated edges yellow, differing pixels red and known issues blue.
The matrix is phone 390×844, tablet 820×1180 and desktop 1280×800, all at 3x, each in light and dark. 3x is used everywhere because a 2 px shift is then 6 device px, far outside the edge tolerance.
Measured (examples/app, default Starter screen)
Measured on macOS 27.0.1 with Playwright WebKit 27.2. A CI runner's numbers are only known after its first run.
| Case | Rects (max Δ) | Differing pixels | Worst tile |
|---|---|---|---|
| phone light / dark | 32/32 (0.32 px) | 0.052 % / 0.040 % | 1.7 % / 1.4 % |
| tablet light / dark | 32/32 (0.16 px) | 0.020 % / 0.017 % | 2.3 % / 2.0 % |
| desktop light / dark | 32/32 (0.16 px) | 0.019 % / 0.017 % | 2.3 % / 2.1 % |
The remaining noise is in text. WebKit snaps text baselines and box edges to device pixels, and glyph advances along a line can drift by about 1 device px. That stays within the rect tolerance and is visible as yellow in the diff.
Self-test
pnpm test:parity:selftest injects small regressions into the web page only, at phone (3x) and desktop. The unmodified baseline must pass, and each mutation must fail on the check it targets:
| Mutation | Fails on | Worst tile (phone / desktop) |
|---|---|---|
.title 2 px lower | rects | 20.6 % / 17.8 % |
| counter button label 2 px lower inside an unchanged box | pixels | 10.5 % / 11.9 % |
| card title indented 2 px | pixels | 26.4 % / 35.1 % |
| lede color token swap | pixels | 18.7 % / 17.6 % |
| counter button background Δ≈18/255 | pixels | 69 % / 70 % |
| card border color | pixels | 6.3 % / 6.3 % |
| card radius 14.4 → 4 px | pixels | 5.4 % / 5.6 % |
The 4 % tile limit sits between today's noise (at most 2.3 %) and the weakest mutation signal (5.4 %).
Known issues
parity.config.json → knownIssues lists real divergences that can't be fixed in the test. Each entry is matched by tag + text prefix, not path, so it survives app restructuring. Its element (the union of its native and web rects) is masked out of the pixel comparison but still rect-checked. The report states whether the issue still reproduces, and an entry that matches nothing, or no longer differs, is flagged for removal.
None are open right now. The last one, a card body that broke before "the" on native and after it on WebKit, was a line-breaking difference: CoreText follows UAX #14, which forbids a break between "the " and ".tsrx", while WebKit breaks after every space. TextBlock now takes WebKit's break opportunities.
Run
pnpm hermes # once: Hermes VM + hermesc
pnpm --filter @octapus/parity-tests exec playwright install webkit # once
pnpm test:parity # build web + mac, build oct-snap, 6 cases
pnpm test:parity -- --no-build --only phone,dark
pnpm test:parity -- --set maxTileDiffRatio=0.03 # override a tolerance
pnpm test:parity:selftestOutput: tests/parity/.out/report/<viewport>-<scheme>/ (native.png, web.png, diff.png, both JSONs), summary.md and report.json. The command exits non-zero on failure. There are no baselines: each run compares web with native directly, so nothing needs updating after an intended UI change. Tolerances live in tests/parity/parity.config.json.
Layer 2: e2e.com flows
tests/e2e uses e2e with two targets and locator-only tests. It uses no agent.* steps, so it needs no model, sign-in or API key. It requires Node ≥ 24.8 (or ≥ 22.22.3).
- web serves
.out/web(built bybuild.mjsfromexamples/appat gitHEAD, so uncommitted work doesn't leak in;APP_ROOT=<dir>overrides) in Playwright WebKit at 440×956, the iPhone 17 Pro Max point size. - ios runs
dev.octapus.examples.brownfieldon an existing simulator (E2E_IOS_DEVICE, a name or UDID; never create one) and opens Octane screen (UIKit) from the native catalog. The installed app must be built from the sameexamples/appas the web target (pnpm ios, then xcodegen + xcodebuild +simctl install). The simulator must not be held by another agent-device session.
macOS has no e2e target: @e2e-dev/desktop is not published in a usable version (0.0.0 on npm). macOS rendering is covered by layer 1, since oct-snap runs the same OctapusCore that the AppKit renderer draws with.
The flow is: open → Count: 0 visible → screenshot → tap the button → Count: 1 visible → screenshot. Baselines are stored per target as tests/counter.e2e.ts-snapshots/counter-{0,1}-{web,ios}-darwin.png. The native HUD (launch timings) is masked.
e2e compares each target only with its own baseline. cross-compare.mjs then compares web with iOS for the same step:
- It finds the iOS content top by aligning the two images vertically (117 pt under the brownfield navigation bar).
- It masks iOS rows above 116 pt (status and navigation bar), in case the content ever slides under the translucent bar. With today's layout the content starts at 117 pt, so this mask is empty. It also excludes e2e's mask color (the HUD).
- It runs the same classifier as layer 1 with a channel threshold of 16, at most 0.6 % differing pixels and at most 18 % per tile.
Screenshots are at 1x (e2e stores device screenshots at point size), so noise is relatively higher: 0.44 % of pixels and 13.3 % in the worst tile, from the 48 pt title. pnpm --filter @octapus/e2e-tests cross:selftest checks that a 2 pt shift of the densest text band, erased text and a wrong color region are all caught. At 1x a 2 pt shift of small body text stays close to the noise floor, so layer 1 is the precise geometry check.
pnpm ios && (cd examples/ios-brownfield && xcodegen generate && xcodebuild … && xcrun simctl install <UDID> …)
pnpm test:e2e # build web, e2e run (web + ios), cross-compare
cd tests/e2e && npx e2e run --target web
npx e2e run --update-snapshots # after an intended UI change: review, commit the PNGsRun the iOS target with a warm frame cache. The first open after installing (or after Clear cached frames) mounts from scratch, and its HUD is one line shorter, which moves the masked area. Record and compare baselines after one prior open. Baselines are per OS (-darwin), so record CI's own baselines from a CI job with -u.
CI
.github/workflows/parity.yml runs layer 1 and its self-test on a macOS runner. Hermes (native/hermes/artifacts, macOS slice) is cached, keyed by the pinned SHA in tools/build-hermes/Plugins/BuildHermes/plugin.swift. The reports are uploaded as an artifact. Layer 2 needs a booted simulator with the app installed, so it runs locally.