zachleigh
1319
9
Testing

Unable to locate factory with name [default]??

Posted 2 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.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.