You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve how to determine if the current request probably expects a JSON response.
That following test can be simplified be adapting [`$request->expectsJson()`](https://github.com/laravel/framework/blob/master/src/Illuminate/Http/Concerns/InteractsWithContentTypes.php#L24)
```diff
public function test_a_user_can_view_any_users()
{
$user = User::factory()->create();
- $jsonResponse = $this->actingAs($user)
- ->withHeaders([
- 'Accept' => 'application/json',
- 'X-Requested-With' => 'XMLHttpRequest',
- ])
- ->get(route('users.index'));
+ $jsonResponse = $this->actingAs($user)->json('GET', route('users.index'));
$jsonResponse->assertSuccessful();
$this->assertArrayNotHasKey('error', $jsonResponse->getData(true));
}
```
0 commit comments