Skip to content

This package adds a couple macros and assertion helpers to your application using Turbo Laravel.

License

Notifications You must be signed in to change notification settings

tonysm/turbo-laravel-test-helpers

Repository files navigation

Turbo Laravel Test Helpers

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 [email protected] 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.

About

This package adds a couple macros and assertion helpers to your application using Turbo Laravel.

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published