title: When using Faker in laravel, how to test the results of API calls?
body: <p>I want to write tests for API calls in Laravel. I have created a model factory to seed my test database so the API calls can return something. Inside the model factory I use Faker to generate random data for the model attributes. I'm using this factory at the beginning of my test, so the data is created during runtime.</p>
  
  <p>How can I  test the results of the API calls? The problem is that during every execution of the test the API call can return different results, due to the randomly generated data. So I cannot just save the result of an APi call in a .json file and compare it with the actual result of the API call in the test.</p>
  
  <p>I am aware of the <code>seeJsonStructure()</code>method ( <a href="https://laravel.com/docs/5.3/application-testing#verifying-structural-match" rel="nofollow noreferrer">https://laravel.com/docs/5.3/application-testing#verifying-structural-match</a> ) but I do not want to use it.</p>
  
  <p>So this is my current attempt which does not work:</p>
  
  <pre class="lang-php prettyprint-override"><code>$cars = factory(Car::class)-&gt;times(2)-&gt;create();
  
  $this-&gt;json('GET', '/api/cars');
  
  $expected = File::get('cars.json');
  
  $this-&gt;seeJson((array) json_decode($expected));
  </code></pre>