title: Laravel Test Inaccurate Result
body: <p>I am testing my api routes in my laravel app, and I struggle why laravel test always inaccurate. To simulate 404 status code, I created a test with non existing route, but it always returns 200 status code.</p>
  <pre><code> public function testTicketsLists()
  {
      $user = factory(User::class)-&gt;create();
      $response = $this-&gt;actingAs($user, 'web')-&gt;withSession(['foo' =&gt; 'bar'])-&gt;get(&quot;api/{$this-&gt;endpoint}/ticketss&quot;);
      $response
          -&gt;assertStatus(404);
      // $response-&gt;dump();
  }
  
  
   Expected status code 404 but received 200. Failed asserting that 404 is identical to 200.
  </code></pre>
  <p>The <code>ticketss</code> endpoint is does not exists so I expected a 404 status code</p>
  <p>api.php</p>
  <pre><code>   /*
  |---------------------------------------------------------------------------
  | services
  |---------------------------------------------------------------------------
   */
  // get all client api methods
  Route::get('services/methods', 'Api\ServicesController@methods');
  // get service lists
  Route::get('services/lists', 'Api\ServicesController@serviceLists');
  // get service details by id per client 
  Route::get('services/{id}/details', 'Api\ServicesController@details');
  // all service ids
  Route::get('services/serviceids', 'Api\ServicesController@serviceids');
  /*
  </code></pre>
  <p>Update, I did some debugging, now I understand why it doesn't return 404 response</p>
  <pre><code>    Illuminate\Testing\TestResponse^ {#8672
      +baseResponse: Illuminate\Http\JsonResponse^ {#7923
  #data: &quot;{&quot;message&quot;:&quot;Page Not Found&quot;,&quot;status&quot;:404,&quot;error&quot;:true}&quot;
  #callback: null
  #encodingOptions: 0
  +headers: Symfony\Component\HttpFoundation\ResponseHeaderBag^ {#7924
    #computedCacheControl: array:2 [
      &quot;no-cache&quot; =&gt; true
      &quot;private&quot; =&gt; true
    ]
    #cookies: []
    #headerNames: array:5 [
      &quot;cache-control&quot; =&gt; &quot;Cache-Control&quot;
      &quot;date&quot; =&gt; &quot;Date&quot;
      &quot;content-type&quot; =&gt; &quot;Content-Type&quot;
      &quot;x-ratelimit-limit&quot; =&gt; &quot;X-RateLimit-Limit&quot;
      &quot;x-ratelimit-remaining&quot; =&gt; &quot;X-RateLimit-Remaining&quot;
    ]
    #headers: array:5 [
      &quot;cache-control&quot; =&gt; array:1 [
        0 =&gt; &quot;no-cache, private&quot;
      ]
      &quot;date&quot; =&gt; array:1 [
        0 =&gt; &quot;Thu, 27 Aug 2020 06:38:52 GMT&quot;
      ]
      &quot;content-type&quot; =&gt; array:1 [
        0 =&gt; &quot;application/json&quot;
      ]
      &quot;x-ratelimit-limit&quot; =&gt; array:1 [
        0 =&gt; 60
      ]
      &quot;x-ratelimit-remaining&quot; =&gt; array:1 [
        0 =&gt; 59
      ]
    ]
    #cacheControl: []
  }
  #content: &quot;{&quot;message&quot;:&quot;Page Not Found&quot;,&quot;status&quot;:404,&quot;error&quot;:true}&quot;
  #version: &quot;1.1&quot;
  #statusCode: 200
  #statusText: &quot;OK&quot;
  #charset: null
  +original: array:3 [
    &quot;message&quot; =&gt; &quot;Page Not Found&quot;
    &quot;status&quot; =&gt; 404
    &quot;error&quot; =&gt; true
  ]
  +exception: null
  }
  #streamedContent: null
  }
  </code></pre>
  <p>The statusCode is always 200, how can I properly test in this scenario ?</p>