I am using mocha/supertest/should.js to test my Rest Service
GET /files/
returns file as stream.
How can I assert in should.js
for comparing large files e.g. images when asserting file uploads a comparison of buffers or strings with should.eql
takes ages. i recommend asserting the buffer hash with the crypto module:
const buf1Hash = crypto.createHash('sha256').update(buf1).digest();
const buf2Hash = crypto.createHash('sha256').update(buf2).digest();
buf1Hash.should.eql(buf2Hash);
an easier approach is asserting the buffer length like so:
buf1.length.should.eql(buf2.length)
instead of using shouldjs as assertion module you can surely use a different tool