- What is nunomaduro/laravel-mojito used for?
- Laravel Mojito is a lightweight, require-dev testing helper for Laravel applications. It hooks into Laravel's view factory so your tests can assert that a view was rendered and which data it received, without actually compiling the Blade template. It is aimed at developers already using PHPUnit and Mockery who want readable view assertions without boilerplate.
- How do I install laravel-mojito?
- Install it as a dev dependency with composer require --dev nunomaduro/laravel-mojito. Then use the Mojito trait in the test case where you want view assertions. There is no configuration to publish, no service container bindings affecting your app, and no database or queue setup involved. The whole integration is a small service provider plus a trait.
- How do I assert that a view was rendered with specific data using Mojito?
- Use assertViewWasRendered() to check that a particular view was rendered, and assertViewWasRenderedWith() to verify the data it received. The API is fluent and small, which keeps controller and HTTP feature tests short and readable. This lets you assert on view contracts rather than scraping rendered HTML strings.
- Which Laravel and PHPUnit versions does laravel-mojito support?
- The package targets the Laravel 5.8 through 8 era and PHPUnit 8 through 9. There are no declared support statements for Laravel 9, 10, or 11, nor for PHPUnit 10 and 11. On a newer stack it may fail to install or behave unpredictably, so check your version matrix before adopting it.
- Does laravel-mojito work with Laravel 10 or Laravel 11?
- There is no declared support for Laravel 9, 10, or 11, and no recent compatibility work has landed upstream. In practice it may install or run, but the project makes no guarantees. If you are on a modern stack and want this API, plan to fork or vendor the small codebase, or use Laravel's native view assertions instead.
- Is nunomaduro/laravel-mojito still maintained?
- Effectively no. Version 0.2.8 arrived after a gap of roughly four years and contains a single small community PR, which does not establish a release cadence. There is still no declared PHPUnit 10 or 11 support and no Laravel 9, 10, or 11 declarations. Treat the unmaintained-upstream risk as real and decide up front who would fork or vendor it if needed.
- How is Mojito different from Laravel's built-in assertViewHas and assertViewIs?
- Laravel already ships assertViewIs, assertViewHas, and Mockery-based View::shouldReceive() helpers, which cover a lot of the same ground. Mojito wraps that into a compact fluent API that some teams find more readable and less boilerplate-heavy. Before adding a dependency, check whether the native assertions already cover most of your view-testing needs.
- Does laravel-mojito add any production overhead or runtime dependencies?
- No. It is a require-dev-only testing utility with no production surface area. It has no database, queue, or config publishing, and no container bindings that affect the application. Its blast radius is bounded to CI: failures surface in your test suite, not in production.
- How do I assert a view was not rendered, or was rendered with empty data?
- Use assertViewWasNotRendered() to confirm a view was never rendered. Version 0.2.8 added an empty-view assertion so a test can express that a view rendered with no meaningful data, without chaining assertViewHas closures. Both are additive, ergonomic wins rather than new capabilities.
- Can Mojito assertions pass vacuously, and what should I use instead?
- Yes, that is the highest-severity concern with any view-testing helper: if its Mockery expectations stop binding to the view factory after a framework upgrade, tests can go green while asserting nothing. Guard against this by writing negative tests that prove your assertions actually fail when a view is not rendered. If you want zero drift risk, stick with Laravel's native assertViewIs, assertViewHas, and View::shouldReceive() helpers, or fork the small Mojito codebase and keep it current yourself.