docs/extend/scout/write-ui-tests.md
Scout UI tests are Playwright tests that use Scout fixtures and page objects for readable, maintainable flows.
:::::{important} Set up your plugin or package first. :::::
tags.*). Scout validates tags at runtime.browserAuth in beforeEach for a clean, readable flow.pageObjects (preferred) or page.gotoApp(...).page.testSubj for data-test-subj-based locators/actions.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.
<plugin-root>/test/scout/ui/tests<plugin-root>/test/scout/ui/parallel_testsSpec files must end with .spec.ts.