Skip to content
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

Add withoutLazyLoading() testing helper #8326

Merged
merged 1 commit into from
Apr 18, 2024

Conversation

calebporzio
Copy link
Collaborator

@calebporzio calebporzio commented Apr 18, 2024

When unit testing a lazy component, or a page with nested lazy components, you may want to disable the "lazy" behavior so that you can assert the final rendered behavior. Otherwise, those components would be rendered as their placeholders during your tests.

This PR adds a Livewire::withoutLazyLoading() helper that can be used like so:

/** @test */
public function renders_successfully()
{
    Livewire::withoutLazyLoading()
        ->test(Dashboard::class)
        ->assertSee(...);
}

Now, when the dashboard component is rendered for this test, it will skip rendering the placeholder() and instead render the full component as if lazy loading wasn't applied at all.

@calebporzio calebporzio marked this pull request as ready for review April 18, 2024 16:34
@calebporzio calebporzio merged commit 01a4ee8 into main Apr 18, 2024
11 of 12 checks passed
@joshhanley joshhanley deleted the add-without-lazy-loading-test-helper branch April 18, 2024 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant