tonysm / turbo-laravel-test-helpers
A couple of testing helpers for applications using Turbo Laravel.
Requires
- php: ^7.4|^8.0
- illuminate/support: ^8.0
- symfony/css-selector: ^5.2
- symfony/dom-crawler: ^5.2
- tonysm/turbo-laravel: ^0.10
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.18
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^9.3
README
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.