zachleigh
6560
11
Testing

Unable to locate factory with name [default]??

Posted 3 years ago by zachleigh

Trying to get Auth up and running on a project and Im running into trouble making model factories for testing. Im getting the following error when trying to create a model with a factory: Unable to locate factory with name [default]
Heres my test:

<?php

namespace App\Tests\Integration;

use App\Tests\TestCase;

class AuthTest extends TestCase
{
    /**
     * @test
     */
    public function it_logs_in_user()
    {
        factory(App\User::class)->create();
    }
}

And my ModelFactorys file:

<?php

$factory->define(App\User::class, function (Faker\Generator $faker) {
    return [
        'name' => $faker->name,
        'email' => $faker->email,
        'password' => str_random(10),
        'remember_token' => str_random(10),
    ];
});

Please sign in or create an account to participate in this conversation.