-
Notifications
You must be signed in to change notification settings - Fork 122
Open
Description
A lot of the tests do not throw an error.
it('should return status 401', async () => { try { await chai.request(server).get(secret); } catch (error) { expect(error.status).to.equal(401); expect(error.response.text).to.equal('Unauthorized'); } });
should be:
it('Should return 401 without token in request', async () => { try { const result = await chai.request(server).get(secret); expect(result.status).to.equal(401); expect(result.response.text).to.equal('Unauthorized'); } catch (e) { throw new Error(e); } });
Because the error in the first example isn't thrown, it causes the assertion to fail, but the test still passes. Remember, try/catch causes the error to not be thrown unless you explicitly tell it to.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels