This package adds a couple macros and assertion helpers to your application using Turbo Laravel. This was built separately because it has different dependencies.
You can install the package via composer:
composer require tonysm/turbo-laravel-test-helpers --dev
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');
}
}
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
This package was generated using the Laravel Package Boilerplate.