Laravel View Test Suite

Laravel is a package for testing views alone. 

class WelcomeTest extends TestCase
// First, add the `InteractsWithViews` trait to your test case class.
use InteractsWithViews;
public function testDisplaysLaravel()
// Then, get started with Mojito using the `assertView` method.

You can also use this package in HTTP tests:

$response = $this->get('/'); $response->assertStatus(200); $response->assertView()->contains('Laravel');

The API includes the following features during authoring:

  • contains() - verifies the text given to view
  • has() - view  verifies the given selector
  • hasAttribute() - verifies that an item is the specified property
  • hasClass() - view verifies that it is given class
  • hasLink() - view verifies the given connection

Here are a few more examples of package methods:

$this->assertView('button')->contains('Click me');
$this->assertView('button')->hasAttribute('attribute', 'value');

You can learn more about this package, get all the installation instructions and view the source code on GitHub from nunomaduro /laravel-mojito .


KARABAY A, 2020 . Laravel View Test Suite,

(Accessed February 19, 2020).

  Share this post

Comments (0)


Sign up for the email newsletter to be the first to know about my blog posts