1

I have a function that can return a few possible rejected promises:

Promise.reject({ a : 'x' })
//  or
Promise.reject({ b : 'y' })
// etc.

I want Chai as Promised to only pass this test if a particular rejection message is returned:

Promise.should.be.rejectedWith({ a : 'x'})

What I have found is that there is no difference between

fooPromise.should.be.rejectedWith({ a : 'x'})

and

fooPromise.should.be.rejectedWith({ foo : 'bar'})

Any rejection will satisfy either of these rejectedWith tests.

Is there a way to specify the rejection body so the test will only pass if that body is returned in the rejected promise under test? I'm using Chai-as-promised 6.0.0.
Thank you

Peter Becich
  • 989
  • 3
  • 14
  • 30

0 Answers0