mockFn.mock.results is always undefined
Steps to reproduce the behavior:
const temp = jest.fn(() => 10);
temp(1);
temp(2);
console.log(temp.mock)
I tested it in my project and here https://jestjs.io/#use
temp.mock.results === [{
value: 10
}, {
value: 10
}]
Sorry, I found out that this functionality exists in 23+ version
Anyone know if it's possible to see the result of a spy using Jest 20.0.4, which comes with create-react-app?
That's not possible, the feature was added in jest 23.0.0.
You have to track it yourself
let returnValues = [];
jest.fn(() => {
const returnThingy = someFunc();
returnValues.push(returnThingy);
return returnThingy;
});
Thanks. A spy that won't tell me what he found? Sounds like a double-agent...
Most helpful comment
Sorry, I found out that this functionality exists in 23+ version