Skip to content

returns() doesn't override returnsArg() #2656

@MartinKolarik

Description

@MartinKolarik

Describe the bug

Since #2593, calling returns(...) on a stub that was previously configured with returnsArg(0) doesn't update the behavior. Instead, the original returnsArg(0) behavior is preserved.

To Reproduce
Steps to reproduce the behavior:

const stub = sandbox.stub();

stub.returnsArg(0);
console.log(stub(1));

stub.returns(42);
console.log(stub(2)); // should log 42, logs 2

Context (please complete the following information):

  • Sinon version : 20.0.0
  • Runtime: Node 20
  • Output of npx envinfo --browsers --binaries:
N/A
  • Other relevant environmental info:
  • Other libraries you are using:
  • Example URL:

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions