#### How to fix Laravel Auth Mocking not working?

I’m trying to mock the Auth facade so I can mock the Auth::user() method. I need this because I source my users from another database.

In production, this all works fine. However, when I try and write tests for this and try something like;

$user = User::factory()->create(); Auth::shouldReceive('user')->andReturn($user);

$response =$this->postJson(route('api.login'), [

MockeryExceptionBadMethodCallException: Received Mockery_2_Illuminate_Auth_AuthManager::userResolver(), but no expectations were specified in Mockery/Loader/EvalLoader.php(34) : eval()'d code:927