# screenshot agent compared en to de and flagged layout shift as bug

## TL;DR

Fixes the screenshot agent flagging expected German text expansion as a layout bug. Compare each locale against its own baseline, not against English. Use when German screenshots fail against English baselines. Not for real truncation bugs.

## The error

```text
Screenshot diff failed: de page differs from en baseline by 34 percent pixel diff from text expansion.
```

## Fix it

### Step 1: Confirm the diff is only text length

```bash
node -e "console.log('review the diff image: longer German words, no broken layout')"
```

Expected: The layout is correct, just wider text.

### Step 2: Baseline per locale

```bash
node -e "console.log('capture a de baseline and compare de against de')"
```

Expected: Each locale compares to its own baseline.

### Step 3: Re-run the suite

```bash
node -e "console.log('confirm the false failure is gone')"
```

Expected: The suite passes with per-locale baselines.

## When to use this

- A locale fails screenshot diff against the English baseline
- The only diff is longer translated text

## When NOT to use this

- Text is actually truncated or overlapping, that is a real bug
- The diff shows missing translations, fix the strings

## Tool and version compatibility

- Playwright and Puppeteer screenshot testing
- Any pixel-diff tool

## Variant phrasings

### fails for every non-English locale

Cross-locale comparison is the wrong strategy. Baseline per locale everywhere.

### passes but hides a real truncation

Per-locale baselines need truncation checks as a separate assertion.

## Why it happens

German text runs about 30 percent longer than English. Comparing a German screenshot to an English baseline flags normal expansion as a defect, burying real regressions in noise.

## Edge cases

- Per-locale baselines must be recaptured when designs change
- Font differences across OSes add diff noise; pin the test fonts
- Combine baselines with explicit overflow assertions

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_12xuw49BWgCb2UHytHS89Q
