New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mocking request query parameters for Livewire #1618
Comments
@calebporzio any chance to get some help on this? |
@faustbrian If you want to test query string stuff, there are examples of how to do it in Livewire's tests. Since that's tested by Livewire, testing it in your own code may be redundant, but that's your call. 👍 |
Yeah I know how to do it with Dusk from the test suite but doing it in unit tests would be my use-case. |
Could you provide some sudo code? So we know how you would imagine an API for this should look like. I don't think that's possible without dusk but you never know 🙂 |
Good call @faustbrian, I think it would be handy to have a way to do this in Livewire's testing utilities. In the past, I've used more outside-in approaches to assert that Livewire handled a query string setter. Here's some not-tested-off-the-top-of-my-head code: $this->get('/the-url/with/the/livewire/component?foo=bar')
->assertSee('bar'); // Assuming that `$foo` is echoed out on the page Other than this I'm not sure what the API would be for the testing utilities. Maybe something like this? Livewire::withQueryParams(['foo' => 'bar'])->test('livewire-component'); Because this isn't a bug necessarily, I'm going to close this issue. Open to a PR thought. |
Bit busy at the moment but I'll try to take a stab at a PR when I find time. |
Description
Since Livewire 2.0 now has the ability to automatically fill properties from the query string, what would be the recommended way to test that Livewire picks up properties from the query string? Is there any easy way to set the query string before the Livewire component is mounted in a test so that it could pick up the query parameters?
Context
The text was updated successfully, but these errors were encountered: