tonysm/turbo-laravel-test-helpers

This package is abandoned and no longer maintained. The author suggests using the tonysm/turbo-laravel package instead.

A couple of testing helpers for applications using Turbo Laravel.

0.10.0 2021-06-23 02:58 UTC

This package is auto-updated.

Last update: 2021-09-24 17:35:57 UTC


README

Latest Version on Packagist GitHub Tests Action Status Total Downloads

This package adds a couple macros and assertion helpers to your application using Turbo Laravel. This was built separately because it has different dependencies.

Installation

You can install the package via composer:

composer require tonysm/turbo-laravel-test-helpers --dev

Usage

Add the trait to your test case. This will make the $this->turbo() method available. This will add the correct header to your response, like so:

use Tonysm\TurboLaravelTestHelpers\Testing\InteractsWithTurbo;

class ExampleTest extends TestCase
{
    use InteractsWithTurbo;
    
    /** @test */
    public function turbo_stream_test()
    {
        $response = $this->turbo()->post('my-route');

        $response->assertTurboStream();

        // Checks if one of the Turbo Stream responses matches this criteria.
        $response->assertHasTurboStream($target = 'users', $action = 'append');

        // Checks if there is no Turbo Stream tag for the criteria.
        $response->assertDoesntHaveTurboStream($target = 'empty_users', $action = 'remove');
    }

    /** @test */
    public function turbo_native_shows()
    {
        $response = $this->turboNative()->get('my-route');

        $response->assertSee('Only rendered in Turbo Native');
    }
}

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email tonysm@hey.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.