Pest: Multiple `uses` statements influence working of test suite

Created on 25 May 2020  路  2Comments  路  Source: pestphp/pest

I added a new line in my Pest.php, below uses(TestCase::class)->in('Feature');:
uses(RefreshDatabase::class)->in('Feature');

Like suggested in https://pestphp.com/docs/underlying-test-case/

After some debugging, with no functionality from TestCase::class, I figured out I had to combine these, or else the latter will override the former, leaving TestCase functionality out of my tests.

This gave me errors like

Unable to locate factory for [App\Category].

and

Call to undefined method Tests\Feature\AddingStatementsToCategoriesTest::get()

when trying to use pestphp on Laravel 7.

I fixed it all this way:

uses(TestCase::class, RefreshDatabase::class)->in('Feature');

Maybe the documentation could be clearer about this, or I'm just stupid for trying ;-).

Most helpful comment

The documentation should now be clearer about the correct usage of uses() : Underlying Test Case.

All 2 comments

You are not stupid :)
Indeed I think we could improve the doc clarity on that point.

You can submit a revised version of the documentation page, just click the "Edit this page" link on the top right 馃檪

If you prefer, you can also open an issue with your edit suggestion on the Pest website repo: https://github.com/pestphp/website and I'll be happy to edit/publish it into the doc.

Thanks!

The documentation should now be clearer about the correct usage of uses() : Underlying Test Case.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

reed-jones picture reed-jones  路  6Comments

nunomaduro picture nunomaduro  路  4Comments

khalyomede picture khalyomede  路  7Comments

olivernybroe picture olivernybroe  路  7Comments

zingimmick picture zingimmick  路  3Comments