Monday 27 April 2020

How to test faking an user is logged in?

Hello all,I am trying to test some of my routes that require an user logged in using Jest + supertest. I use jspassport and I create a session per user logged in. The session ID is stored in a cookie.The problem I am facing is that when I run the test, I do a request to login and it returns status code 200, so it seems ok. However, if I do a subsequent request to a route that requires login it does not work. I guess it is because there is no session id attached in the cookie as there are no cookies when running the test (correct me if I am wrong please).Therefore, how would you tackle this problem?Thank you in advance and regards

Submitted April 28, 2020 at 07:05AM by dejavits

No comments:

Post a Comment