set('tenancy.features', [CrossDomainRedirect::class]); } $this->app->register(new TenancyServiceProvider($this->app)); Route::get('/foobar', function () { return 'Foo'; })->name('home'); Route::get('/redirect', function () { return redirect()->route('home')->domain('abcd'); }); try { pest()->get('/redirect') ->assertRedirect('http://abcd/foobar'); if ($shouldThrow) { pest()->fail('Exception not thrown'); } } catch (Throwable $e) { if ($shouldThrow) { pest()->assertTrue(true); // empty assertion to make the test pass } else { pest()->fail('Exception thrown: ' . $e->getMessage()); } } })->with([ ['enabled' => false, 'shouldThrow' => true], ['enabled' => true, 'shouldThrow' => false], ]);