Error says that you have $newPosts variable somewhere, and you pass $newestPosts to views. Search in your code for newPosts and change it to newestPosts.
Hi
i switch to Feature test, but have same issue.
it seems Tests\Features not instantiate data while boot the framework
because $newestPost get from AppServiceProvider , not from controller
<?php
namespace Tests\Feature;
use Tests\TestCase;
use App\Models\Post;
use App\Models\Community;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
class PageTest extends TestCase
{
use RefreshDatabase;
protected $seed = true;
public function testHomepage()
{
$this->withoutExceptionHandling();
$response = $this->get('/');
$response->assertStatus(200);
}