vendredi 5 mai 2017

How to test chai with yield generator with exception

I'm trying to test a generator that should always throw an exception:

function* failureFunc() {
  yield* getThing('blabla'); //throws an error
}

How should I build the chai expect / should expression correctly? So far I couldn't get an expression to work I have tried:

chai.expect(yield* failureFunc()).to.throw(Error);
chai.expect(yield* failureFunc()).to.be.rejectedWith(Error);

tried also adding some chai-generator functions. Nothing seems to work. Not sure what is the correct way to build this expression.

Aucun commentaire:

Enregistrer un commentaire