mockFn.mock.results is always undefined
See original GitHub issue🐛 Bug Report
mockFn.mock.results is always undefined
To Reproduce
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
Expected behavior
temp.mock.results === [{
value: 10
}, {
value: 10
}]
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
Top Results From Across the Web
jest.fn() inside jest.mock() returns undefined - Stack Overflow
So in our case, the mock function was being included in the mocked module at test runtime, but that mock had been reset,...
Read more >Mock Functions - Jest
mockFn.mock.results . An array containing the results of all calls that have been made to this mock function. Each entry in this array...
Read more >Mock Functions - Jest - w3resource
Mock functions helps us make testing of links between code easy, by erasing the actual implementation of a function, capturing the calls to ......
Read more >Mock Functions or Spies Demystified - How Does jest.fn() Work?
We need to add the instances and results arrays to our mock state object: 1 // 3. Mock state 2 mockFn.
Read more >API Reference | Vitest
If spy wasn't called, will return undefined . mock.results #. This is an array containing all values, that were returned from function. One...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry, I found out that this functionality exists in 23+ version
Thanks. A spy that won’t tell me what he found? Sounds like a double-agent…