I figured it out,
I was extending PHPUnit\Framework\TestCase instead of Tests\TestCase.
Doh!
Summer Sale! All accounts are 50% off this week.
Hi,
When running php artisan test the default User factory returns
InvalidArgumentException
Unknown formatter "name"
Using the same factory in for example web.php works fine, it only breaks when it is used in a test.
I have tested in a clean Laravel 8 install, only added $user = User::factory()->create(); to tests\Unit\ExampleTest.php
What am I missing?
Actually, by default, PHPUnit\Framework\TestCase is used for Unit tests and not only in the ExampleTest.
Indeeed, It will also be the case when you run:
php artisan make:test RandomTest --unit
This is made so that Unit tests can run faster.
The framework isn't booted and you get the speed boost for these types of test: https://github.com/laravel/laravel/pull/5169
On the other hand, Feature tests use Tests\TestCase by default.
Please or to participate in this conversation.