question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

5reactions
pavel06081991commented, Jul 9, 2018

Sorry, I found out that this functionality exists in 23+ version

3reactions
jacobwebercommented, Sep 19, 2018

Thanks. A spy that won’t tell me what he found? Sounds like a double-agent…

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found