I have a simple test that should be failed but it passed with an error.
My code:
it('my test', async () => {
const result = await resolvingPromise;
expect(result).to.equal('ok');
async function analyzeData() {
let getData = db.getData(1);
let data = await getData;
expect(data.field).to.equal(null);
}
analyzeData();
});
In this test first expect is ok but the expect inside the async function must fail but test returns me that is passed but I have seen this error:
UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): AssertionError: expected Fri, 02 Mar 2018 09:47:06 GMT to equal null
(node:295) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
how can I handle a rejectin this way? or I need to change my async functuion here in test? What is the good approach so?
Aucun commentaire:
Enregistrer un commentaire