Protone Media logo

Hey! Did you hear about Laravel Splade? 🤩

It's the magic of Inertia.js with the simplicity of Blade. Splade provides a super easy way to build Single Page Applications using Blade templates. Besides that magic SPA-feeling, it comes with more than ten components to sparkle your app and make it interactive, all without ever leaving Blade.

Mixing the Laravel 5.4+ HTTP testing layer with BrowserKit testing

Laravel 5.4 (January, 2017) came with the introduction of Laravel Dusk, a first-party package with support for browser automation and a corresponding testing API. The HTTP testing layer got rewritten and became much more focussed on APIs from Laravel 5.4 onwards. Some of the HTTP testing tools were removed and bundled in the optional browser-kit-testing package.

You can use the rewritten HTTP testing layer in Laravel 5.4+ and the 'old' Laravel 5.3 testing layer side-by-side. What you can't do is mix those two in one test. I wrote a little package which solves that constraint. It contains just one macro which adds a browserKit method to the TestResponse class. This way you can make and test requests with the new layer and do assertions with the old layer.

Now why would you do that? Laravel 5.4+ provides a lot of assertions for responses but the old layer has some gems too, for example: seeElement. Take a look at the Laravel 5.3 TestCase to find some other cool ones. In the example below I'm mixing the two testing layers, you can find the package at GitHub.

/** @test */
public function it_presents_a_registration_form()
        ->browserKit(function ($test) {
            $test->seeElement('input', ['name' => 'email']);

Related posts

Want to stay up-to-date on Laravel news and packages?

Pascal Baljet on Twitter

Follow me on Twitter: @pascalbaljet

Pascal Baljet on Twitter

Subscribe to my YouTube channel

© 2013-2023 Protone Media B.V. Hosted with Eddy Server Management.