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.

Handle nested mocked values

See original GitHub issue

As the title says, when there are nested callable values, I would expect those to be typed as mocked values too.

interface ResourcesApi {
    get(id: string): Promise<any>
}

interface Api {
    resources: ResourcesApi
}

const api = mock<Api>()

// The next line will get a type error because `get` isn't mocked.
api.resources.get.mockReturnValue(true)

Thoughts?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
marchaoscommented, Dec 11, 2019

Yep, looking to add support for deep mocks. Will see if I can add support for this without the need for a extra arg

0reactions
marchaoscommented, Dec 20, 2019

Merged this - currently opt in - will update the readme

Read more comments on GitHub >

github_iconTop Results From Across the Web

mock nested method calls using mockito - java - Stack Overflow
Try by creating mock of each of the nested object and then mock the individual method called by each of these object.
Read more >
Mock nested method calls using Mockito in Spring Boot
Mock nested method calls using Mockito in Spring Boot ; 1, Session session = ; 2, connectionFactory.createConnection() ; 3 .createSession(Session.
Read more >
Stubbing in nested test classes in combination with ... - GitHub
A workaround I found for some cases like these is defining the mocks with @Mock(answer = org.mockito.Answers.RETURNS_DEEP_STUBS) and not using @ ...
Read more >
Deep Mocking | mockzilla
A mocking toolkit leveraging the power of TypeScript to enhance your jest ... You have a deeply nested API, like the browser object...
Read more >
Mocking functions declared in nested headers, and union ...
Hi,. I've been using Ceedling for a while, and am now trying to generate CMock mocks for a module that has nested headers....
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