title: ReferenceError: formData is not defined
body: <p>I am writing a unit testing code for the Ajax and Laravel project. I am trying to test one function.</p>
  
  <pre><code>&lt;script&gt;
      $(document).ready(function () {
          $('#postAdd').click(function(e){
  
              e.preventDefault();
  
              var form = $('#addPost');
              formData.append('file', $('input[type=file]')[0].files[0]);
  
              $.ajax({
                  type: "POST",
                  url: "{{ route('posts.store') }}",
                  data: formData,
                  success: function (response) {
                      console.log(response)
                  },
                  error: function (error) {
                      console.log(error)
                  }
              })
          })
      })
  &lt;/script&gt;
  </code></pre>
  
  <p>In the browser, this works ok. but when testing I get below error in console</p>
  
  <blockquote>
    <p>ReferenceError: formData is not defined</p>
  </blockquote>