d

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore.

15 St Margarets, NY 10033
(+381) 11 123 4567
ouroffice@aware.com

 

KMF

Livewire Make Command can now Scaffold a Component Test

Livewire v2.4.0 was just released with added support for a --test option when running the php artisan livewire:make command.

The new --test option, when included, will scaffold a test class for the component in the tests/Features/Livewire directory similar to the php artisan make:test command.

php artisan livewire:make ExampleComponent --test

<?php

namespace TestsFeatureLivewire;

use AppHttpLivewireExampleComponent;
use IlluminateFoundationTestingRefreshDatabase;
use IlluminateFoundationTestingWithFaker;
use LivewireLivewire;
use TestsTestCase;

class ExampleComponentTest extends TestCase
{
    /** @test */
    public function the_component_can_render()
    {
        $component = Livewire::test(ExampleComponent::class);

        $component->assertStatus(200);
    }
}

I’ve been working on several Livewire projects lately and creating new components every day, so I had the idea to create this option in order to save me (and other Livewire users) time. Instead of having to create a new component, then manually creating a test class, just add the --test option and start writing your tests!

Credit: Source link

Previous Next
Close
Test Caption
Test Description goes like this