Skip to content

.throws() in conjuction with .onFirstCall() doesn't work #1526

@RiddleMan

Description

@RiddleMan

Hi,

After upgrade to Sinon 3.2.0, I've spotted that some of my tests are failing.
As a result of a quick investigation, I've found that .throws() is not throwing when it's used together with .onFirstCall(), onCall() etc.

I've checked this issue for .withArgs() and it seems to work correctly.

  • Sinon version : 3.2.0
  • Environment : nodejs
  • Example URL :
  • Other libraries you are using:

What did you expect to happen?
It should throw an Error only on the first call or no of the call specified in the .onCall() method.
What actually happens
It doesn't throw any error.
How to reproduce

  const stub = sinon.stub();
  stub
    .onFirstCall()
    .throws();

  try {
    stub();
    console.log('WRONG');
  } catch(e) {
    console.log('OK');
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions