# Turn a bug into a test

Source: https://zshot-cli.com/examples/agent-regression-test/
Markdown: https://zshot-cli.com/examples/agent-regression-test/index.md
Section: [Examples](https://zshot-cli.com/examples/)
License: [Pro](https://zshot-cli.com/support/licenses/pro)

Ask an agent to check one behavior of [Zoomburgh](https://zshot-cli.com/example_assets/zoomburgh/): tapping a company in the watchlist should show its news. The goal is text from Arbor Outfitters' first headline. The navigator taps Arbor Outfitters, finds the news panel still empty, and reports the goal impossible. ZShot saves the page it ended on to [`arbor-outfitters.png`](/example-renders/arbor-outfitters.png) and the session to [`news-test.js`](/example-renders/news-test.js), a Playwright script. The navigator in this example uses Anthropic with an API key you must provide.

**CLI**

```sh
zshot -f arbor-outfitters.png \
  --navigate "Tap Arbor Outfitters in the watchlist once, then check that its news headlines appear within five seconds. Do not tap it again." \
  --navigator-goal "text:Analysts lift ARRC price target" \
  --navigator-renders-when-impossible \
  --navigator-captures-playwright news-test.js \
  --navigator-type "anthropic://YOUR_API_KEY@" \
  https://zshot-cli.com/example_assets/zoomburgh/
```

Expected output: [arbor-outfitters.png](/example-renders/arbor-outfitters.png) — Zoomburgh with Arbor Outfitters selected and its news panel reading No news for ARRC

The script repeats the navigator's steps, then waits for the goal:

```js
  // step 1: CLICK [row]
  await click(page.locator("tbody > tr:nth-of-type(2)"));

  // step 2: WAIT
  await page.waitForTimeout(5000);

  // goal: text:Analysts lift ARRC price target
  await page.waitForFunction((text) => (document.body ? document.body.innerText : '').includes(text), "Analysts lift ARRC price target");
```

Replay it against ZShot. It needs the `playwright` package but no browser of its own:

```sh
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install playwright
zshot --cdp -- node news-test.js
```

The headline never appears, so the replay fails the same way and ZShot exits with the script's code, `1`:

```text
page.waitForFunction: Timeout 30000ms exceeded.
```

Once the news loads on the first tap, the same command exits `0`, so the script can stay in a test suite as a regression test.

## Related

Flags:

- [`--navigator-captures-playwright`](https://zshot-cli.com/reference/flags/navigator/navigator-captures-playwright/)
- [`--cdp`](https://zshot-cli.com/reference/flags/server/cdp/)
- [`--navigator-goal`](https://zshot-cli.com/reference/flags/navigator/navigator-goal/)
- [`--navigator-renders-when-impossible`](https://zshot-cli.com/reference/flags/navigator/navigator-renders-when-impossible/)

Topics:

- [Navigator](https://zshot-cli.com/reference/navigator/) — How the navigator works
- [news-test.js](https://zshot-cli.com/example-renders/news-test.js) — The recorded script

## Navigation

- [Examples](https://zshot-cli.com/examples/)
  - [Webpage as PNG](https://zshot-cli.com/examples/hello-from-zshot/)
  - [Full-page phone screenshot](https://zshot-cli.com/examples/full-page-phone/)
  - [Wait for a JavaScript event](https://zshot-cli.com/examples/wait-for-event/)
  - [Rendered HTML](https://zshot-cli.com/examples/html-output/)
  - [Tablet screenshot](https://zshot-cli.com/examples/tablet-screenshot/)
  - [Dark mode](https://zshot-cli.com/examples/dark-mode/)
  - [Emulate geolocation](https://zshot-cli.com/examples/geolocation/)
  - [Accessible PDF](https://zshot-cli.com/examples/accessible-pdf/)
  - [WebM video](https://zshot-cli.com/examples/webm-video/)
  - [Animated GIF](https://zshot-cli.com/examples/animated-gif/)
  - [Log in, then capture](https://zshot-cli.com/examples/navigate-login/)
  - [Log in, then extract JSON](https://zshot-cli.com/examples/sales-report-json/)
  - [Upload a file, download the result](https://zshot-cli.com/examples/enhance-leads/)
  - **Turn a bug into a test**
  - [Crawl a site into a WACZ](https://zshot-cli.com/examples/crawl-links/)
  - [Archive a sitemap into a WACZ](https://zshot-cli.com/examples/wacz-sitemap/)
  - [Run an API server](https://zshot-cli.com/examples/api-server/)
  - [Signed URL support](https://zshot-cli.com/examples/menu-board/)
  - [Browser as a CDN](https://zshot-cli.com/examples/browser-as-a-cdn/)
- [Download](https://zshot-cli.com/download/)
- [Purchase](https://zshot-cli.com/purchase/)
- [Reference](https://zshot-cli.com/reference/)
- [Support](https://zshot-cli.com/support/)
- [Changelog](https://zshot-cli.com/changelog/)

Site index: https://zshot-cli.com/llms.txt

