Weave 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 Mojito

Laravel Mojito Laravel Package

nunomaduro/laravel-mojito

Laravel Mojito is a lightweight testing helper by Nuno Maduro that simplifies mocking Laravel facades. Define expectations and return values with a clean, fluent API, keeping tests fast and readable without boilerplate.

View on GitHub
Deep Wiki
Context7

A lightweight package for testing Laravel views.

Frequently asked questions about Laravel Mojito
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.
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.
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo
bernskioldmedia/laravel-harvest
bernskiold/laravel-data-scrubber
bernskiold/laravel-currency-converter
bernskiold/laravel-campaign-monitor
bernskioldmedia/laravel-autotranslate
siberfx/telegram-bot
roy-sandip/laravel-view-extended
gregsphotography/site-builder-core
roy-sandip/laravel-view
anodyne/blade-fluentui-icons
webx-ui/module-catalog-collections