Skip to content

DeepPartial support in vi.mocked #8152

Closed

Description

@Tsmith18256

Clear and concise description of the problem

The vi.mocked type helper currently only supports partials at the surface level. If the return type of a function contains nested objects, there's no way to do a deep/recursive partial. This can require mocking a lot of unnecessary fields.

Particularly with APIs that return a tuple of a success object and an error (eg: [data, err]). The partial flag doesn't really do anything here, data must still be fully mocked to pass the type checks.

Suggested solution

I would be happy to send in a PR to add support for a DeepPartial. I would be looking for some guidance on what the ideal API for that would be in the options object of vi.mocked. I had originally expected setting { partial: true, deep: true } to do what I'm describing, so it's going to be tricky to add a flag that's clear in what it does and what separates it from the existing flags.

Alternative

No response

Additional context

No response

Validations

Activity

  1. sheremet-va commented on Dec 22, 2025

    @sheremet-va
    Member

    Feel free to open a PR with a fix. I think partial: true, deep: true should support that.

  2. locked and limited conversation to collaborators on Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    p2-nice-to-haveNot breaking anything but nice to have (priority)

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions