=============== LIBRARY RULES =============== From library maintainers: - Check rendered HTML with a CSS selector, never as a string or a regular expression. - Select by tag, role, aria-*, label or text, then by a data-* marker; a class is a value to check with toHaveSelectorClass(). - A check of one node needs exactly one match; narrow to a region with within(). - Give a check its reason as the last argument; after the optional value of toHaveSelectorAttribute(), pass it by name: message: '…'. ### Install skill as Claude Code plugin Source: https://github.com/sorge-it/phpunit-pest-html-assertions/blob/main/README.md Install the skill as a plugin in Claude Code by adding the marketplace and then installing the plugin. ```text /plugin marketplace add sorge-it/phpunit-pest-html-assertions /plugin install phpunit-pest-html-assertions@sorge-it ``` -------------------------------- ### Install skill with npx skills Source: https://github.com/sorge-it/phpunit-pest-html-assertions/blob/main/README.md Install the skill for other agents (Cursor, Codex, GitHub Copilot) using the `skills` CLI. ```sh npx skills add sorge-it/phpunit-pest-html-assertions ``` -------------------------------- ### Install with Composer Source: https://github.com/sorge-it/phpunit-pest-html-assertions/blob/main/README.md Install the package as a dev dependency. When Pest is installed, Composer registers the expectations automatically, so tests/Pest.php needs no line. ```sh composer require --dev sorge-it/phpunit-pest-html-assertions ``` -------------------------------- ### Add package to boost.json Source: https://github.com/sorge-it/phpunit-pest-html-assertions/blob/main/README.md Add the package to the `packages` array in `boost.json` so Laravel Boost installs the guideline and skill for the agent. ```json { "packages": ["sorge-it/phpunit-pest-html-assertions"] } ``` -------------------------------- ### toHaveSelectorClass example with class as value Source: https://github.com/sorge-it/phpunit-pest-html-assertions/blob/main/README.md Example of using a CSS class as a value to check with toHaveSelectorClass, not as a selector. The class is the expected value, while the selector is a data-* marker. ```text toHaveSelectorClass('[data-status]', 'bg-red-500') ``` -------------------------------- ### Failure message for a check that fails Source: https://github.com/sorge-it/phpunit-pest-html-assertions/blob/main/README.md Example failure message when a check fails. Shows the path of regions, what was asked, what was found, and the region itself as indented HTML, cut at 40 lines. ```text Failed asserting that (page) > [data-cart] has one node matching "[data-name="Pear"]" with the text "Pear, ripe". Its text is "Pear". In (page) > [data-cart]: