@kkdev92/vscode-ext-kit - v4.1.1
    Preparing search index...

    Interface MockFn<TArgs, TReturn>

    The subset of vi.fn() / jest.fn()'s returned mock function that this kit relies on: callable, and chainable with the handful of mock* helpers actually used to build the vscode mock. Both Vitest's Mock<T> and Jest's jest.Mock<T> satisfy this structurally, so no vitest/jest type import is ever required here. This interface is a portability boundary, not an attempt to expose every runner-specific spy assertion/helper.

    interface MockFn<TArgs extends unknown[] = unknown[], TReturn = unknown> {
        mock: {
            calls: unknown[][];
            results: { type: "return" | "throw" | "incomplete"; value: unknown }[];
        };
        mockClear(): this;
        mockImplementation(fn: (...args: TArgs) => TReturn): this;
        mockImplementationOnce(fn: (...args: TArgs) => TReturn): this;
        mockRejectedValue(reason: unknown): this;
        mockRejectedValueOnce(reason: unknown): this;
        mockResolvedValue(value: Awaited<TReturn>): this;
        mockResolvedValueOnce(value: Awaited<TReturn>): this;
        mockReturnValue(value: TReturn): this;
        mockReturnValueOnce(value: TReturn): this;
        (...args: TArgs): TReturn;
    }

    Type Parameters

    • TArgs extends unknown[] = unknown[]
    • TReturn = unknown
    Index
    mock: {
        calls: unknown[][];
        results: { type: "return" | "throw" | "incomplete"; value: unknown }[];
    }

    Recorded invocations and their outcomes, matching vi.fn()/jest.fn()'s own .mock object.

    Arguments and returned values are kept as unknown rather than TArgs/TReturn on purpose: a test overriding one of this kit's mock fields with a fresh, more loosely typed vi.fn()/jest.fn() (a common per-test override) must stay assignable, and callers reading these almost always either toEqual(...) the result or cast it explicitly anyway.

    results is what makes a factory-shaped mock testable: it's the only way to reach the object a call returned — e.g. the channel handed back by window.createOutputChannel — so assertions can be made against it. 'incomplete' is part of the union because both runners use it for a call that is still in flight; narrow on type === 'return' before trusting value.

    • Makes every future call return a promise rejected with reason.

      Parameters

      • reason: unknown

      Returns this

    • Makes the next call only return a promise rejected with reason.

      Parameters

      • reason: unknown

      Returns this