pest
pest copied to clipboard
[Bug]: Upgrade of `collision` causes Pest to crash
What Happened
Typed static property P\Tests\Feature\MyTest::$__latestDescription must not be accessed before initialization
How to Reproduce
Use datasets and upgrade nunomaduro/collision
to version 7.8.1
or higher.
Pest Version
2.22.0
PHP Version
8.2.3
Operation System
Linux
Notes
Downgrading nunomaduro/collision
to 7.8.0
fixes the issue.
Hey, @michael-rubel ! Thanks for your report.
I was unable to reproduce the issue based on a new Laravel project, for example. I'm interested in knowing why a Collision update was necessary?
@devajmeireles I was doing a regular composer update in the project, and Pest crashed after that.
If that would help, all dependencies that were downgraded alongside collision
to make it work again:
With those versions, it does work. Still, upgrading only collision
to 7.8.1
(without upgrading others) causes the error.
@devajmeireles Seems the same as https://github.com/pestphp/pest/issues/963
@devajmeireles I was doing a regular composer update in the project, and Pest crashed after that.
If that would help, all dependencies that were downgraded alongside
collision
to make it work again:
We continue unable to reproduce the issue. I've started a new Laravel project and updated the composer dependencies and all works fine after the update. Could you share a repository example, please?
@michael-rubel Without a way to reproduce the issue locally, we can't help.
@nunomaduro @devajmeireles
I found that this bug is triggered by https://github.com/nunomaduro/collision/pull/280/files#diff-401856c982d2b2da6aa98709f2114b7d9421aca0687db29a66d56db27b2ae6f5R232
But it seems the root cause is not this, but the fact that datasets stopped being loaded from the subfolders in a global Datasets
folder:
Inside the Companies.php
I have datasets like this:
If I move Companies.php
to the Datasets
root, then the $__latestDescription
error disappears, and Pest starts working.
I'd create a PR to fix it, but it looks like it's something related to the getScopedDataset
logic, and not sure what the author meant by str_starts_with($currentTestFile, $datasetScope)
filtering condition in this case.
Also a thought: the project is quite old and we were upgrading the app from Pest 1.x
to Pest 2.x
. This change could have arrived in 2.x
, but we haven't noticed that those tests were not running because PHPUnit internal errors were not reported?
I think dataset is not scoped correctly because it checks if it's parent folder is called Datasets, maybe we can fix it by extending the check to any parent folder in the filetree
I was having the same issue after upgrading to pest v2 and I found the bug in the Datasets.
Solution:
Make sure to use \Pest\Faker\fake()
not \Pest\Faker\faker()