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
Solution using file-compare
and node-temp
:
it('should return test2.json as a stream', function (done) {
var writeStream = temp.createWriteStream();
temp.track();
var req = api.get('/files/7386afde8992');
req.on('end', function() {
comparator.compare(writeStream.path, TEST2_JSON_FILE, function(result, err) {
if (err) {
return done(err);
}
result.should.true;
done();
});
});
req.pipe(writeStream);
});