Skip to content

sinon.stub().resolves(...) returns undefined when used with createStubInstance #2073

@clemmy

Description

@clemmy

Describe the bug
This was working in 7.3.2, but broke in 7.4.1.
Basically, when calling sinon.stub().resolves(...) as part of the second argument of sinon.createStubInstance(), I get undefined. It works as a standalone, however.

To Reproduce
Steps to reproduce the behavior:
Run the following test:

class X {
  async test() {
    return Promise.resolve(1)
  }
}

it('is a buggy test', async () => {
  const thing = sinon.createStubInstance(X, {
    test: sinon.stub().resolves(2) as sinon.SinonStub<[], Promise<number>>
  })
  console.log(thing.test()) // undefined
}

Expected behavior
I would expect the console.log(thing.test()) to output 2

Screenshots
N/A

Context (please complete the following information):

  • Library version: 7.4.1
  • Environment: Mac OSX
  • Example URL: n/a
  • Other libraries you are using: n/a

Additional context
N/A

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