Skip to content

stub also verified warning when using ignoreExtraArgs #181

Closed
@ackerdev

Description

@ackerdev

When attempting to create reusable doubles, I found an oddity with the behavior of the "test double was both stubbed and verified" warning when using ignoreExtraArgs.

As a simple (contrived) example:

const foo = td.function();

td.when(foo(), { ignoreExtraArgs: true }).thenReturn(bar);
td.verify(foo());

The intention behind this is to stub behavior of foo that consistently returns bar, regardless of arguments, while the verify call is to ensure that foo was called with 0 arguments. Because the stubbing is defined without arguments, the warning is displayed, even though ignoreExtraArgs should imply that these invocations are not 1-to-1 identical. It is possible to work around this with td.matchers.anything() in the stubbing, though not ideal.

My usecase for this is creating a reusable double to stand in for a somewhat complex third party interface that is passed in as an argument to my function; specifically, hapi's reply interface.

This is seems somewhat related to #180, a functionality limited by the stubbing api, though I think it's a distinct issue worth documenting.

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