How to check if two files have the same content?

前端 未结 6 639
说谎
说谎 2021-02-05 10:35

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

6条回答
  •  旧时难觅i
    2021-02-05 10:49

    In should.js you can use .eql to compare Buffer's instances:

    > var buf1 = new Buffer('abc');
    undefined
    > var buf2 = new Buffer('abc');
    undefined
    > var buf3 = new Buffer('dsfg');
    undefined
    > buf1.should.be.eql(buf1)
    ...
    > buf1.should.be.eql(buf2)
    ...
    > buf1.should.be.eql(buf3)
    AssertionError: expected  to equal 
        ...
    > 
    

提交回复
热议问题