loadEnvironmentFrom('.env.testing'); // specify the file to use for environment, must be run before boostrap $app->make(Kernel::class)->bootstrap(); $this->clearCache(); // NEW LINE -- Testing doesn't work properly with cached stuff. return $app; } /** * Clears Laravel Cache before testing */ protected function clearCache() { $commands = ['clear-compiled', 'cache:clear', 'view:clear', 'config:clear', 'route:clear']; foreach ($commands as $command) { \Illuminate\Support\Facades\Artisan::call($command); } } }