Skip to content

Mocking a single method #182

Open
Open
@gCardinal

Description

@gCardinal

Is ts-mockito able to mock a single function? I've been trying without much success and I'm worried that it's not a supported use case... This lib has been a real blessing to work with so far (it's still pretty new to me) I'd hate to have to switch back to sinon...

Anyway, to a concrete example:

export type GameResponseNormalizer = (response: Promise<any>) => Game
export interface RestClient {
    post: (uri: string, params: object)
}

export const createGame = (client: RestClient, normalizer: GameResponseNormalizer): Promise<Game> => {
    // ... Boring implementation
}

Creating a mock for RestClient is pretty basic, but would ts-mockito be able to create a mock for GameResponseNormalizer?

Sometimes it's just not worth building a whole class for very simple behaviors or methods. Especially in a functional language like JS or TS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions