Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Dom Assertions

Laravel Dom Assertions Laravel Package

sinnbeck/laravel-dom-assertions

Extra DOM assertion helpers for Laravel HTTP tests. Assert elements, text, forms, selects, and datalists with more precision than assertSee/SeeText. Works with Livewire and Blade views/components; includes quick existence checks and a method reference.

View on GitHub
Deep Wiki
Context7

Adds DOM assertions to laravels test responses

Frequently asked questions about Laravel Dom Assertions
How do I install this package for Laravel 10+ with PHP 8.1?
Run `composer require sinnbeck/laravel-dom-assertions --dev` in your project. The package is a dev dependency and won’t affect production. Ensure your `composer.json` specifies Laravel 10+ and PHP 8.1+ in requirements.
Can I use this package with Livewire components?
Yes, the package includes Livewire-specific assertions like `assertFormExists()` and `findSelect()` to test dynamic content. Use `assertElementExists()` on Livewire responses, and chain methods like `find()` to traverse nested elements.
What’s the difference between `assertElementExists()` and Laravel’s `assertSee()`?
`assertElementExists()` provides granular DOM assertions (e.g., checking attributes, forms, or selects) with fluent chaining, while `assertSee()` only verifies text presence. This package supports complex selectors, ARIA attributes, and hierarchical traversal.
Does this package work with Alpine.js or Inertia.js?
Yes, it works with Alpine.js by asserting dynamic attributes (e.g., `x-data` or `x-bind`) and Inertia.js by validating page structure. Use `find()` to locate elements with Alpine reactivity markers or Inertia’s page IDs.
How do I test forms with this package?
Use `assertFormExists()` to verify form presence, then chain methods like `findInput()` or `findSelect()` to validate fields. Example: `assertFormExists()->findInput('email')->assertHasValue('test@example.com').`
Will this package slow down my test suite?
Minimal overhead—DOM parsing adds ~10–30ms per assertion. Mitigate by limiting assertions to critical paths or using parallel test runners like PestPHP’s `--parallel`. Benchmark in CI to ensure no regression.
Can I use this with Laravel 9 or PHP 8.0?
Yes, install version 2.x with `composer require sinnbeck/laravel-dom-assertions:^2.0 --dev`. Check the [README](https://github.com/sinnbeck/laravel-dom-assertions) for version-specific features.
How do I handle flaky tests with dynamic content (e.g., Livewire)?
Use `waitFor()` or `refresh()` methods to retry assertions on dynamic content. Example: `assertElementExists()->waitFor(2)->find('#dynamic-element')`. Avoid timing-based waits; prefer explicit retries.
Are there alternatives for complex JavaScript testing?
For heavy JavaScript (e.g., SPAs), use Playwright or Cypress instead. This package focuses on server-rendered DOM assertions—ideal for Laravel’s Blade/Livewire but not full frontend testing.
How do I assert ARIA attributes or accessibility features?
Use `assertElementExists()->assertHasAttribute('aria-label', 'Submit')` or `assertHasRole('button')`. The package supports ARIA roles, labels, and semantic HTML validation for accessibility testing.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor