{"library":"playwright-expect","title":"Playwright-Expect Assertion Library","description":"playwright-expect is an assertion library designed for enhancing end-to-end testing with Playwright Test and Jest. Currently at version 0.1.2, it significantly extends the default `expect` API with a richer set of matchers compared to similar libraries like `expect-playwright`, aiming to provide a more comprehensive and robust testing experience. Key differentiators include an extensive collection of easy-to-use assertions, exhaustive failure messages with diff highlights, options for case-insensitive matching and trimming values before assertion, and the ability to automatically wait for expectations to succeed. It seamlessly integrates with both Playwright Test and Jest and ships with built-in TypeScript types for improved developer experience and autocompletion. The project maintains an active patch release cadence, focusing on stability and feature enhancements.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install playwright-expect"],"cli":null},"imports":["import { matchers } from 'playwright-expect';","const { matchers } = require('playwright-expect');","import { expect } from '@playwright/test';\nexpect.extend(matchers);"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { test, expect } from '@playwright/test';\nimport { matchers } from 'playwright-expect';\n\n// Extend Playwright's expect with playwright-expect's custom matchers\nexpect.extend(matchers);\n\ntest('has title and interactive elements', async ({ page }) => {\n  await page.goto('https://playwright.dev/');\n\n  // Using toContainTitle matcher (from playwright-expect) with options\n  await expect([page, 'title']).toContainTitle('Playwright', { ignoreCase: true, timeout: 5000 });\n\n  // Using toHaveText matcher (from playwright-expect) on a locator\n  const header = page.locator('h1');\n  await expect(header).toHaveText('Playwright', { trim: true });\n\n  // Interact with an element and assert its new state\n  await page.locator('.get-started').click();\n  // toHaveText can wait for the element to have the text\n  await expect(page.locator('h1')).toHaveText('Installation', { timeout: 7000 });\n\n  // Verify a checkbox is not checked initially, then check it and assert\n  const checkbox = page.locator('input[type=\"checkbox\"]');\n  await expect(checkbox).not.toBeChecked();\n  await checkbox.check();\n  await expect(checkbox).toBeChecked();\n});","lang":"typescript","description":"Demonstrates how to install playwright-expect, extend Playwright's `expect` object, and use various custom matchers with options like `ignoreCase`, `trim`, and `timeout` in a Playwright Test setup.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}