Loading

Write Scout UI tests

Scout UI tests are Playwright tests that use Scout fixtures and page objects for readable, maintainable flows.

  • Tags: every suite needs one or more deployment tags (use tags.*). Scout validates tags at runtime.
  • Authentication: use browserAuth in beforeEach for a clean, readable flow.
  • Navigation + actions: use pageObjects (preferred) or page.gotoApp(...).
  • Selectors: use page.testSubj for data-test-subj-based locators/actions.
  • Assertions: import expect from your Scout package’s UI entrypoint (for example @kbn/scout/ui or @kbn/scout-<solution>/ui).

This pattern is a good default:

import { tags } from '@kbn/scout';
import { expect } from '@kbn/scout/ui';
import { test } from '../fixtures';

test.describe('My feature', { tag: tags.deploymentAgnostic }, () => {
  test.beforeEach(async ({ browserAuth, pageObjects }) => {
    await browserAuth.loginAsViewer();
    await pageObjects.discover.goto();
  });

  test('shows the main table', async ({ page }) => {
    await expect(page.testSubj.locator('discoverDocTable')).toBeVisible();
  });
});
		
Tip

Prefer APIs for setup/cleanup (for example apiServices, kbnClient) in beforeAll/afterAll instead of doing expensive setup through the UI. If the same one-time setup is shared across many suites (archives, ingest, settings), move it to a global setup hook.

If your suite can be isolated, put it under parallel_tests/ and use spaceTest to get one Space per worker via scoutSpace. See Parallelism and the global setup hook.

  • Sequential UI tests: <plugin-root>/test/scout/ui/tests
  • Parallel UI tests: <plugin-root>/test/scout/ui/parallel_tests

Spec files must end with .spec.ts.