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

[Bug]: Error when running test using a forelse #1147

Open
felipeArnold opened this issue Apr 30, 2024 · 2 comments
Open

[Bug]: Error when running test using a forelse #1147

felipeArnold opened this issue Apr 30, 2024 · 2 comments
Labels

Comments

@felipeArnold
Copy link

What Happened

My livewire component expects to receive a collection or null, when receiving null and running the test, using the @forelse directive, it reports an error in the test saying that "Illuminate\View\ViewException: foreach() argument must be of type array|object, null given", adding an if around foreach works normally, follow images for better viewing.

public ?Collection $comments = null;

How to Reproduce

image
image
image
image

Sample Repository

No response

Pest Version

v2.34.7

PHP Version

8.3

Operation System

Windows

Notes

No response

@devajmeireles
Copy link
Member

Have you tried inserting a @dd to debug the value inside the comments?

@felipeArnold
Copy link
Author

yes, returns null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants