testbench-core
testbench-core copied to clipboard
Trait to test Inertia Controller
As we spoke here I created a trait to test a controller, which response with inertia response. To use this you need to do the following:
- Create a new file named app.blade.php in your package's resources/views directory.
- Call the load function from the trait
class FooTest extends BaseTest
{
use WithInertia;
protected $inertiaMiddleware = HandleInertiaRequests::class;
}
You can customize the Finder using:
use Illuminate\View\FileViewFinder;
class FooTest extends BaseTest
{
use WithInertia;
protected $inertiaMiddleware = HandleInertiaRequests::class;
public function defineEnvironment($app): void
{
$this->defineInertia(function (FileViewFinder $finder) {
$finder->addNamespace('WD', __DIR__.'/../../UI/resources/app/Pages');
});
}
}
To define custom paths or register view location.
$this->defineInertiaPages(view: 'resources/views', paths: ['resources/js/Pages']);
Coverage: 82.913% (-0.6%) from 83.537% when pulling f3d1183e5fa71507499591d1fa67a97d060e4c95 on snake-py:8.x into 2e4b270fb01cec9219a17944513804175faba27f on orchestral:8.x.
@crynobone I am unsure if I can assist here in any way. I see that you split up the code. SHould I try to tackle this or do you want to do it?