title: Read response output buffer/stream with supertest/superagent on node.js server
body: <p>I am trying to write a test that checks whether an API route outputs a ZIP file with the correct contents.</p>
  
  <p>I am using mocha and supertest for testing, and I would like to actually read the output stream/buffer, read the zip file contents and see if the contents are correct.</p>
  
  <p>Any ideas how should I do it? When I try to read <code>res.body</code>, it's just an empty object.</p>
  
  <pre><code>  request(app)
      .get( "/api/v1/orders/download?id[]=1&amp;id=2" )
      .set( "Authorization", authData )
      .expect( 200 )
      .expect( 'Content-Type', /application\/zip/ )
      .end( function (err, res) {
        if (err) return done( err );
  
        console.log( 'body:', res.body )
  
        // Write the temp HTML file to filesystem using utf-8 encoding
        var zip = new AdmZip( res.body );
        var zipEntries = zip.getEntries();
  
        console.log( 'zipentries:', zipEntries );
  
        zipEntries.forEach(function(zipEntry) {
          console.log(zipEntry.toString()); // outputs zip entries information
        });
  
        done();
      });
  </code></pre>