8000 Make error messages for tests with mocked functions more explicit / "Strict stubbing mode ?" · Issue #66 · TypeStrong/ts-mockito · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Make error messages for tests with mocked functions more explicit / "Strict stubbing mode ?" #66
Open
@Raazor

Description

@Raazor

Hello,

We are currently evaluating multiple options for unit testing in our NodeJS backend. Since I am coming from Java / SpringBoot background I naturally prepared a PR to showcase how cool it is to develop mocks with the mockito syntax.

In general a lot of use cases are already supported. It would be nice to have less ambiguous error messages if something goes wrong with setting up mocks while writing tests for example. I remember that for Java there is some kind of strict stubbing: you would get an error if there is a message called which is not mocked - or vice-versa when you would mock a method that is not called in the test execution. It does not have to go so much into detail. but any way of more specific error messages would be awesome.

Here is an example:

Image

So since the mocked method (in src file line: 100) is not working when you adjust a parameter it will just be null, and of course fail because we run .catch() on it in the code. It would be nice to get an actual insight that shows the difference in the mocked parameters: expected param: ip; actual: ip + 'thisIsNotMockedForSure' for method call ... .

Thank you in advance for any feedback 👍

Best regards,

Martin

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0