柴等于失败

时间:2016-09-22 22:14:03

标签: mocha chai

var realtypeof = function(obj) {
    switch (typeof(obj)) {
        case 'object':
            if (obj instanceof Array)
                return 'array';
            else if (obj instanceof Date)
                return 'date';
            else if (obj instanceof RegExp)
                return 'regexp';
            else
                return 'object';
        default:
            return typeof(obj);
    }
};

var msg = Message.decode(data);
console.log(realtypeof({
    text: 'text',
    lang: 'lang'
}));
console.log(realtypeof(msg));

console.log({
    text: 'text',
    lang: 'lang'
});
console.log(msg);

expect(msg).to.equal({
    text: 'text',
    lang: 'lang'
}, 'response not correct');

结果:

object
object
{ text: 'text', lang: 'lang' }
{ text: 'text', lang: 'lang' }
  1) returns a protocbuf message

  1 failing

  1) Protobuf API GET protobuf returns a protocbuf message:

      response not correct
      + expected - actual


      at Request.<anonymous> (test/protobuf.js:71:32)
      at IncomingMessage.<anonymous> (node_modules/request/request.js:969:12)
      at endReadableNT (_stream_readable.js:926:12)
      at _combinedTickCallback (internal/process/next_tick.js:74:11)
      at process._tickCallback (internal/process/next_tick.js:98:9)

当我在JSON.stringify中包装它时,它可以工作。但是它在http://chaijs.com/api/bdd/#method_equal说明你可能有两个不同的对象?

0 个答案:

没有答案