[Bug]: Pest internally throws `$__latestDescription must not be accessed before initialization` when data provider returns empty array, instead of the expected `InvalidDataProviderException`
What Happened
Here is a minimal reproduction test case:
test('example', function () {
expect(true)->toBeTrue();
})->with(function () {
return [];
});
It looks like this is supposed to be throwing an InvalidDataProviderException exception alerting me that my data provider appears incorrect (src/Metadata/Api/DataProvider.php):
However, it is actually throwing a PHP error attempting to access the $__latestDescription variable:
How to Reproduce
- Create a brand new Composer project
./vendor/bin/pest --init- Add the above minimal reproduction test case to the automatically-generated example unit test.
Sample Repository
No response
Pest Version
3.8.1
PHP Version
8.3.19
Operation System
Linux
Notes
As a side note, it would be helpful if there was a mechanism to indicate "I expect no datasets here".
I have a different open issue (https://github.com/pestphp/pest/issues/1369) regarding filtering of test, and my workaround is to return an empty dataset array when a CLI filter is provided. This workaround no longer works due to the InvalidDataProviderException, and it took a significant amount of time to realize that the $__latestDescription must not be accessed before initialization error was generated by Pest due to something going wrong when handling the InvalidDataProviderException