Hi there!
The code I provided in this article clears out the database after every test. If that's not what you want, you can delete the contents of the afterEach function to avoid losing your data after every test.
However, keep in mind that if you're using mongodb-memory-server as your test database, every time you run the tests the database is created from scratch, so you'll have to populate any test data you need before running the tests (I'd do it in the beforeAll function, for example).
Hope this helps!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi there!
The code I provided in this article clears out the database after every test. If that's not what you want, you can delete the contents of the
afterEach
function to avoid losing your data after every test.However, keep in mind that if you're using mongodb-memory-server as your test database, every time you run the tests the database is created from scratch, so you'll have to populate any test data you need before running the tests (I'd do it in the
beforeAll
function, for example).Hope this helps!