M220JS - Chapter 2: Ticket: User management

Hello everybody,
I have just successfully completed the ticket of chapter 2: User management.
However, I have a doubt.
I went to the main page and created a new user.
I then logged in and checked that the new document was inserted on the database in the sessions collection.
When I logged out, however, the document was not deleted.


Hi @Sarma_Crea, :wave:
Did you restart your server, after making the changes?

Is this always the case or is it a one-off thing?

In case you have any doubts, please feel free to reach out to us.

Thanks and Regards.
Sourabh Bagrecha,
Curriculum Services Engineer

Hi @SourabhBagrecha ,
thank you for your answer.
I tried to restart the server, but I always get the same result.
This is what I can see from the console

POST /api/v1/user/login 200 233.518 ms - 287
GET /api/v1/movies/facet-search?cast=Denzel%20Washington&page=0 304 276.220 ms - -
GET /api/v1/movies/facet-search?cast=Morgan%20Freeman&page=2 304 210.569 ms - -
POST /api/v1/user/logout 500 1.181 ms - 2

Please post a screenshot of of the result of the unit tests.

1 Like


I am assuming that you aren’t running multiple databases? Local/Docker and Atlas?

I am, which I was why I was mentioning it :slight_smile:

Or you hard coded some entries for the test scripts?


1 Like

Thanks to @steevej and @NeilM

I am using only one database in ATLAS.

I haven’t changed the test scripts.

This is what I get when I run the test script.

npm test -t user-management
server@1.0.0 test E:\mflix-js
jest --passWithNoTests “user-management”
Determining test suites to run…Setup Mongo Connection
(node:11204) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to MongoClient.connect.
(Use node --trace-deprecation ... to show where the warning was created)
Browserslist: caniuse-lite is outdated. Please run next command npm update
PASS test/user-management.test.js
User Management
√ it can add a new user to the database (163ms)
√ it returns an error when trying to register duplicate user (48ms)
√ it allows a user to login (117ms)
√ it allows a user to logout (97ms)
Test Suites: 1 passed, 1 total
Tests: 4 passed, 4 total
Snapshots: 0 total
Time: 4.394s
Ran all test suites matching /user-management/i.
Teardown Mongo Connection