mardi 28 août 2018

I am mocking a function instance(es5) using jest but not able to mock it properly

My code is as below ->

let mockFunction = jest.fn().mockImplementation((a) => {
    this.temp = a;
});

When I instantiate this function as follows

let mockFn = new mockFunction(6);
console.log(mockFn.temp) //this gives me undefined instead of 6

How can I access the instance in the mockImplementation function?

Aucun commentaire:

Enregistrer un commentaire