Extend Playwright's testing power with custom, expressive matchers.
Playwright's built-in expect API is great, but sometimes you need more specialized assertions for your tests. playwright-assertions lets you write clearer, more maintainable tests by using custom matchers for common testing needs—covering arrays, strings, URLs, dates, and much more, with ongoing growth from community contributions.
Why use this?
- Make your tests more readable and intention-revealing
- Reduce boilerplate and repetitive assertion logic
- Easily share custom matchers across projects and teams
npm install playwright-assertionsNote: You must have
@playwright/testinstalled.
Import and use the extended expect in your Playwright tests:
import { expect } from 'playwright-assertions';
// Example matcher:
expect([1, 2, 2, 3]).toHaveDuplications();
expect([1, 2, 3]).not.toHaveDuplications();This library aims to provide a rich set of assertions for:
- Arrays
- Strings
- URLs
- Dates
- And many other common data types
See the documentation and matcher list for details as the library grows.
This package is an ongoing effort and currently missing many common assertions. We are actively working to expand the matcher set, and contributions are highly encouraged!
If you have ideas for new matchers or improvements, please open an issue or submit a pull request.
We welcome contributions to add new matchers, improve documentation, or fix bugs.
- Fork the repository
- Create a new branch for your feature or fix
- Write tests for your changes
- Submit a pull request
Please follow the existing code style and add documentation for any new matchers.
MIT