Skip to Content
HeyBug docs
Concepts

Choose the viewport for tests

The viewport is the browser window size that every run and exploration in a project uses.

The viewport is the browser window size that every run and exploration in a project uses. A layout test sees the page at that width, so a menu that folds away on a phone only shows up when the viewport is phone-sized. Set it once per project in Run behaviour.

Presets

PresetSize (CSS px)Use it for
Desktop1920 x 1080The default. Full navigation, multi-column layouts.
Tablet834 x 1194Portrait tablets, collapsed side menus.
Mobile390 x 844Phone layouts, menu buttons, stacked forms.
CustomWidth 200 to 7680, height 200 to 4320Any other size you need.

Presets only change the window size. They do not emulate a device, so touch input and device user agents are not set.

Set the viewport

  1. Open your project and choose Settings (/p/{project}/settings).
  2. In Run behaviour, pick a preset under Viewport. For Custom, enter a width and height in pixels.
  3. Choose Save run behaviour. The status shows Saved.

Runs and explorations that start after you save use the new size. A project with no saved settings uses Desktop.

The setting is also available over the API, as the viewport field of the run behaviour object:

curl -s "$HEYBUG_SERVER/api/projects/$PROJECT_ID/settings/run-behavior" \
  -H "Authorization: Bearer $HEYBUG_TOKEN"

A PUT replaces every run behaviour field, so read the object first and send all of it back with your change:

curl -s -X PUT "$HEYBUG_SERVER/api/projects/$PROJECT_ID/settings/run-behavior" \
  -H "Authorization: Bearer $HEYBUG_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"viewport":"custom","width":1280,"height":720,"maxTests":50,"testIdAttributes":["data-testid","data-test","data-qa"],"exploreBrowserMinutes":15}'

The response is the saved object. heybug run, the CLI and the heybug_run MCP tool do not take a viewport flag, so the project setting is the one to change. There is no per-plan or per-run override yet.

Effect on layout tests

  • Breakpoints. Responsive CSS and media queries use the viewport width. Pick the preset that matches the layout you want to test.
  • Screenshots. Step screenshots are taken at the viewport size. Open a failed step in the run and check the screenshot to see the layout the browser had.
  • Hidden controls. On Mobile, a control behind a menu button is not visible until the menu opens. A test that expects it on the page should say so, or run at Desktop.

For how a failed step is shown, see Reading results.

When it fails

  • "A custom viewport needs a width of 200 to 7680 and a height of 200 to 4320." The size is outside the allowed range. The error names the field, so fix that value and save again.
  • Exploration fails with "viewport width and height must be integers between 200 and 4096". The browser that explores the app accepts sizes up to 4096 px on each side, while settings allow more. Use a Custom size of 4096 px or less for both sides, or choose a preset.
  • A layout test fails only at one size. Check the viewport in settings, then open the step screenshot. If the layout is wrong at that width, the test found a real bug. If the test expects a different layout, adjust the test instructions and run again.
  • You need a second size. Run the project once per size by changing the setting between runs. Each run uses the viewport saved when it started.

If none of this matches, see Troubleshooting.

  • Getting started: create a project and run your first test.
  • MCP: run tests from an AI assistant. The run uses the saved viewport.
  • CLI: run tests from a terminal with the same project settings.
  • Reading results: step screenshots and failure details.
  • Troubleshooting: common errors and fixes.

On this page