Skip to content

Instantly share code, notes, and snippets.

@adamliptrot-oc
Last active March 11, 2025 10:29
Show Gist options
  • Select an option

  • Save adamliptrot-oc/042ebf50e2715bdbe3f459c0ce711a54 to your computer and use it in GitHub Desktop.

Select an option

Save adamliptrot-oc/042ebf50e2715bdbe3f459c0ce711a54 to your computer and use it in GitHub Desktop.
State tests with Playwright
test('open account menu actions', async ({ page }) => {
const logInButton = page.getByRole('button', {name: 'login', expanded: false});
await logInButton.press('Enter');
const accountMenu = page.locator('#account-menu');
const accountMenuClose = page.locator('#account-menu-close')
// check menu is visible
await expect.soft(accountMenu).toBeVisible();
// check button aria has updated
await expect.soft(logInButton.toHaveAttribute('aria-expanded','true'));
// check close button in dialog is focused
await expect.soft(accountMenuClose).toBeFocused();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment