pest icon indicating copy to clipboard operation
pest copied to clipboard

[Bug]: Cannot use Datasets in subfolders

Open dantes4ur opened this issue 11 months ago • 8 comments

What Happened

As part of my transition from Laravel 9 to Laravel 10, I am also upgrading from Pest 1.x to 2.x. During this process, I encountered an issue concerning the resolution of datasets located within subfolders.

I'm not the only one with this problem, please refer to [laracast question] for more details. (https://laracasts.com/discuss/channels/testing/pest-global-datasets-not-allowed-in-modular-project)

How to Reproduce

Construct a dataset and place it within a subfolder inside the Datasets directory. Afterwards, execute the command ./vendor/bin/pest MyTest.php, which unfortunately results in a failure.

However, this situation is peculiar as executing the test through PHPStorm does not present any issues, indicating that the problem only occurs when running the test from the terminal...

Sample Repository

No response

Pest Version

2.34.4

PHP Version

8.2.16

Operation System

macOS

Notes

No response

dantes4ur avatar Mar 25 '24 23:03 dantes4ur

Same issue here (it's my post)

girardotcl avatar Mar 26 '24 07:03 girardotcl

hi, would you mind to share here your test directory structure?

fabio-ivona avatar Mar 26 '24 07:03 fabio-ivona

Sure, this is my general structure:

Captura de pantalla 2024-03-26 a la(s) 1 37 25 a m

The core issue lies with the handling of Datasets; specifically, the inability to organize them into a Folder/Subfolder structure, as Pest fails to recognize the dataset in such a configuration. This is particularly rare because this limitation was not present in Pest 1.0 afaik...

Captura de pantalla 2024-03-26 a la(s) 1 39 15 a m

Something defined within ExampleDataset.php and ExampleDataset2.php won't be loaded.

Hope this clarifies the issue

dantes4ur avatar Mar 26 '24 07:03 dantes4ur

Hi !

Thanks for your work.

Any update on this issue ?

girardotcl avatar Apr 08 '24 06:04 girardotcl

Hi !

Thanks for your work.

Any update on this issue ?

Working on this one, there are some caveats to fix, will be ready in a couple of days

fabio-ivona avatar Apr 08 '24 07:04 fabio-ivona

Awesome, thank you very much for your work !

girardotcl avatar Apr 08 '24 09:04 girardotcl

I've found a weird behaviour when running parallel tests, maybe someone's willing to have a deeper look here #1134

fabio-ivona avatar Apr 11 '24 13:04 fabio-ivona

I have decided to make my own abstraction for my global datasets, it's ugly but it's working.

girardotcl avatar Aug 07 '24 06:08 girardotcl