Skip to content

Ability to mock that a function throws an Error #67

Description

@rodrigopsasaki

I haven't found this anywhere and I feel like the library should handle this. I even looked at open and closed tickets but couldn't find this functionality.

I'd like to be able to have my mocked dependencies throw exceptions, for example:

const calculatorMock = Substitute.for<Calculator>();
calculatorMock.add(1, 1).throws(new Error('error message'))

Is there any reason why this is not supported?

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