Write

Screenshots and clips

Capture product images and short clips from a running app.

Product images go out of date when the UI changes. Driftless captures them with a script, so you can take them all again in one command.

Screenshots

List each screen in driftless.config.ts:

capture: {
  appUrl: 'http://127.0.0.1:3000',
  themes: ['light', 'dark'],
  // Optional: runs once in Node, for example to sign in. Its result is passed to init.
  setup: async ({ appUrl }) => ({ token: await signIn(appUrl) }),
  // Runs in the page before each load. It is sent to the browser as text, so use only its arguments.
  init: (theme, data) => {
    localStorage.setItem('theme', theme);
    localStorage.setItem('token', data.token);
  },
  views: [
    { name: 'home', path: '/' },
    { name: 'new-item', path: '/items', selector: '[role=dialog]',
      prepare: async (page) => { await page.getByRole('button', { name: 'New item' }).click(); } },
  ],
  clips: [],
},

Then run:

npx playwright install chromium ffmpeg   # once
npm run screenshots

Each view gives public/product/<name>-light.webp and <name>-dark.webp. The page shows the image that matches the reader’s theme:

<Screenshot name="home" alt="The home page with three projects." />

Clips

A clip shows a short flow, such as a drag or a multi-step change. Write the steps with Playwright:

clips: [
  { name: 'create-item', path: '/items', steps: async (page) => {
      await page.getByRole('button', { name: 'New item' }).click();
      await page.getByLabel('Name').fill('Quarterly report');
      await page.waitForTimeout(400);
      await page.getByRole('button', { name: 'Save' }).click();
  } },
],
npm run clips            # .webm for the docs
npm run clips -- --gif   # also a .gif, for READMEs and pull requests

Clips need ffmpeg to trim the page load and to make GIFs.

<Clip name="create-item" alt="Creating an item called Quarterly report." />

Rules

  • Use demo or seed data. Never show customer data, real names, keys or internal hostnames.
  • The script captures only from localhost or 127.0.0.1. To capture from a test server that holds only demo data, set CAPTURE_ALLOW_REMOTE=1. Never capture a customer deployment.
  • If the app has no demo data, write a seed script, and a mock server for any paid API it calls. The Open WebUI example has both.
  • Keep view names stable, because pages refer to them.
  • Keep a clip under 10 seconds.