node.js - Jest does not know the instance of an object in parameter -


when use jest, can't know types (instance) of object in parameter.

example :

class customerror1 extends error {    constructor(reason, myid) {      super(reason);      this.id = myid;    } }  class customerror2 extends error {   constructor(reason, secondid) {     super(reason);     this.secondid = secondid;   } }  myfunction(id, callback) {   if(id === 1) {     return callback(new customerror1('1', id ));   } else {     return callback(new customerror2('2', id ));   } } 

if use jest (with jest.fn or sinon have same result (but works mocha))

let c = jest.fn(); myfunction(1, c);  expect(c.mock.calls[0][0].constructor.name).tobe('error'); // true expect(c.mock.calls[0][0]).tobeinstanceof(customerror1);   // false -- it's object :s 

how can know type of object using jest ?


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -