Skip to content

static methods in mocked classes is missing in typescript #8850

@alvis

Description

@alvis

Describe the bug

In v4, class mocking finally arrived. However, static methods are missing from the export, despite it's illustrated from the document.

Reproduction

const Dog = vi.fn(class {
  static getType = vi.fn(() => 'mocked animal')
})

Dog.getType // <- it is inaccessible in typescript

System Info

vitest v4.0.4

Used Package Manager

pnpm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    p3-minor-bugAn edge case that only affects very specific usage (priority)

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions