Skip to content

returns clears fake's callArgAt #2572

Closed
@fpascutti

Description

@fpascutti

Describe the bug
Starting from [email protected], using returns clears fake's callArgAt.
This means that the callback will not be called.

To Reproduce
Run the following:

const sinon = require("sinon");
const assert = require("assert");

const stub = sinon.stub();
stub.callsArgWith(0, "Hello").returns("World");

const cb = sinon.stub();
const ret = stub(cb);

assert.strictEqual(ret, "World");
assert(cb.calledOnce);
assert.deepEqual(cb.firstCall.args, ["Hello"]);

Expected behavior
The callback should be properly invoked.

Context (please complete the following information):

  • Library version: 17.0.1
  • Environment: Windows / Node.JS

Additional context

Bug introduced by the fix for #2566 (see #2567).
Might be fixed by removing this line but this needs validation.

+@rluvaton

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions