问题描述
我正在重新安装Livewire 2和Laravel 8,但是在尝试运行PHPunit测试时,我得到了RuntimeException : A facade root has not been set.
。我尝试了标准的缓存清理,但似乎没有任何效果。还有其他人看到吗?如果正在运行完整测试,则在下面。
<?PHP
namespace Tests\Unit;
use App\Http\Livewire\Properties\CreateProperty;
use Livewire\Livewire;
use PHPUnit\Framework\TestCase;
class CreatePropertyTest extends TestCase
{
/**
* @test
*/
public function form_has_expected_labels()
{
Livewire::test(CreateProperty::class)
->assertSee('Property Name')
->assertSee('Address');
}
}
解决方法
从以下位置更改TestCase的use语句
use PHPUnit\Framework\TestCase;
到
use Tests\TestCase;