Resolve failing test in backend
Lazytangent opened this issue · comments
DELETE /api/checkIns/5 403 0.624 ms - 3700
FAIL __tests__/checkInRoutes.js
● CheckIn routes › DELETE /api/checkIns/:checkInId › should return an error message if no user authenticated
expected "Content-Type" matching /json/, got "text/html; charset=utf-8"
145 | .delete(`/api/checkIns/${checkIn.id}`)
146 | .expect(403)
> 147 | .expect("Content-Type", /json/);
| ^
148 |
149 | expect(res.body).toEqual(
150 | expect.objectContaining({
at Object.<anonymous> (__tests__/checkInRoutes.js:147:10)
----
at Test.Object.<anonymous>.Test._assertHeader (node_modules/supertest/lib/test.js:273:14)
at node_modules/supertest/lib/test.js:80:15
at Test.Object.<anonymous>.Test._assertFunction (node_modules/supertest/lib/test.js:311:11)
at Test.Object.<anonymous>.Test.assert (node_modules/supertest/lib/test.js:201:21)
at Server.localAssert (node_modules/supertest/lib/test.js:159:12)
That's the error message that showed up when that test failed.
The 403
error code comes from the CSRF middleware, so it doesn't show up in the codebase whenever the code runs. Since the tests, the others it was based on, were testing for the failure that comes from not being logged in when doing these actions, the error code should really be 401
.