【发布时间】:2014-11-05 03:35:29
【问题描述】:
我正在使用mocha/supertest/should.js 测试 REST 服务
GET /files/<hash> 将文件作为流返回。
如何在should.js 中断言文件内容相同?
it('should return file as stream', function (done) {
var writeStream = fs.createWriteStream('test/fixtures/tmp.json');
var req = api.get('/files/676dfg1430af3595');
req.on('end', function(){
var tmpBuf = fs.readFileSync('test/fixtures/tmp.json');
var testBuf = fs.readFileSync('test/fixtures/test.json');
// How to assert with should.js file contents are the same (tmpBuf == testBuf )
// ...
done();
});
});
【问题讨论】:
标签: javascript node.js compare mocha.js should.js