Can you show the code?
Are you using bound datasets? If not, try using them
Summer Sale! All accounts are 50% off this week.
Has anyone used faker in factories that are then used in a Pest dataset?
I get an error: Unknown format "firstName".
Directly in the Pest test they work fine, its only in datasets.
Is there something I've missed?
Figured it out properly - I was not using the WithFaker class.
<?php
use App\Group;
use App\User;
uses(\Illuminate\Foundation\Testing\WithFaker::class);
dataset('users_with_groups', function () {
yield 'No Group' => fn () => User::factory()->make();
yield 'No Access' => fn () => User::factory()->create([
'group_id' => Group::factory()->create(['name' => 'no Access'])
]);
yield 'Standard' => fn () => User::factory()->standard()->create();
yield 'Product' => fn () => User::factory()->product()->create();
yield 'Limited' => fn () => User::factory()->limited()->create();
yield 'Readonly' => fn () => User::factory()->readonly()->create();
yield 'Administrator' => fn () => User::factory()->administrator()->create();
});
Please or to participate in this conversation.