chaijs / chai-as-promised

Extends Chai with assertions about promises.
MIT License
1.42k stars 112 forks source link

Error: Invalid Chai property: _promise #260

Open Alena1985 opened 4 years ago

Alena1985 commented 4 years ago

The error occures when i try to test error case for async method. So i have

it("service should catch exception when it is raised", async() => {
   const error = new Error();
   sandbox.stub(Service, "method").withArgs(arg1, arg2 ).rejects(error);//this method is called in Api.serviceMethod, it is async too
   await expect(Api.serviceMethod(arg1, arg2)).to.be.rejectedWith(error);

if instead of async/await i use just return expect(Api.serviceMethod(arg1, arg2)).to.be.rejectedWith(error); it works properly