fullstack-hy2020 / fullstack-hy2020.github.io

https://fullstack-hy2020.github.io
Other
1.54k stars 3.89k forks source link

Update part4c.md to prevent unexpected test failures #3683

Open VovaTitarenko opened 3 months ago

VovaTitarenko commented 3 months ago

Tests concerning POSTing new notes failed with an enexpected 500 "Internal Server Error" after adding the update-user functionality to controllers/notes.js router since userId is now required for Mongoose to return the corresponding user object. I added a warning that this the exact reason for test failures so that other students don't spend too much time debugging the code.

P.S. For my tests to pass I also rewrote the beforeEach method since, if the userbase is cleared completely everytime, there will never be a stable userId that can be securely passed inside newNote objects to test the POST functionality.