Mocking (testing) Query Parameters in Livewire

How can I test that a Laravel request parameter (from the mount method) is passed successfully to the Livewire component?

Example:

public function mount()
{
    $this->parameters = request()->input();
}

Test:

public function test_mounts_request_parameters()
{
    (new Request([], ['foo' => 'bar']));
    Livewire::test(LivewireComponent::class)
        ->assertSet('parameters', ['foo' => 'bar']);
}

Result:

Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
 Array (
-    'foo' => 'bar'
 )

Which request you are trying to call in the mount() method exactly?

Take a look at this example:

...
    public $title;

    public function mount($initialTitle = '')
    {
        $this->title = $initialTitle;
    }
...
    /** @test  */
    function can_set_initial_title()
    {
        $this->actingAs(factory(User::class)->create());

        Livewire::test(CreatePost::class, ['initialTitle' => 'foo'])
            ->assertSet('title', 'foo');
    }

I Think you are missing the second parameter on test() method

For more info see test section in livewire docs

No, that wouldn’t work… request() is Laravel’s native request object. I’m using it to obtain the URL query parameters…

Apparently you can’t do this but Caleb is open to contributions.