PHPackages                             ziadoz/assertable-html - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. ziadoz/assertable-html

ActiveLibrary[Templating &amp; Views](/categories/templating)

ziadoz/assertable-html
======================

 Assertable HTML is an elegantly designed PHPUnit library that makes performing assertions on HTML responses from PHP and Laravel applications quick and enjoyable.

442[1 issues](https://github.com/ziadoz/assertable-html/issues)PHPCI passing

Since Oct 6Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/ziadoz/assertable-html)[ Packagist](https://packagist.org/packages/ziadoz/assertable-html)[ RSS](/packages/ziadoz-assertable-html/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

[![Assertable HTML](art/logo.png)](art/logo.png)

---

Assertable HTML takes a fresh approach to testing HTML responses generated by templating engines such as Blade and Twig in PHP and Laravel web applications. It provides an elegant interface that allows developers to fluently navigate and target their HTML using modern CSS selectors, and then write effective test assertions against the results.

**Key Features:**

- **Fluent Interface:** Navigate and target HTML elements using an API similar to native JavaScript.
- **Minimal Interface:** Work with a stripped back API that’s focused on testing.
- **Chainable Assertions:** Quickly chain together multiple assertions on elements.
- **Flexible Assertions:** Supply callbacks for complex element assertions if the built-in ones aren’t sufficient.
- **Element-Specific Assertions:** Use element-specific assertions to quickly test forms and other elements (**Coming Soon**).

Important

There may be some breaking changes with this package until it hits v1.0.0.

Table Of Contents
-----------------

[](#table-of-contents)

- [Get Started](#-get-started)
    - [Requirements](#requirements)
    - [Installation](#installation)
    - [PHPUnit Installation](#phpunit-installation)
    - [Laravel Installation](#laravel-installation)
- [Usage](#-usage)
    - [Basics](#basics)
    - [Scopes](#scopes)
    - [Assertions](#assertions)
    - [Assertion Messages](#assertion-messages)
    - [Flexible Assertions](#flexible-assertions)
    - [Element-Specific Assertions](#element-specific-assertions)
    - [HTML Output](#html-output)

🚀 Get Started
-------------

[](#-get-started)

### Requirements

[](#requirements)

- PHP 8.4+
- Composer
- Laravel &gt;=11.41.0 (if applicable)

### Installation

[](#installation)

You can install the package using Composer:

```
composer install ziadoz/assertable-html
```

### PHPUnit Installation

[](#phpunit-installation)

If you're using PHPUnit, simply include the trait in your test class:

```
