Good testing setup with Mocha? #584
-
Hello everyone, what is a good approach when it comes to testing with Mocha and MongoDB? Mongodb memory server seems like the perfect fit, but I've been unable to get it setup properly. Do you setup your server once before all tests or before each test/ test block? As Unit tests and integration tests for that manner, should have a clean DB to avoid unusual behaviour. This is 50% Mocha and 50% MDB Memory server question but I am guessing I'll have more luck asking here. If anyone would be willing to share their setup, mine can be found here alongside the issues I am facing. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
i dont quite know you specifications, but there is Integration with Test Runners: Mocha / chai, which may be outdated, because we (maintainers) dont really use mocha / chai anymore, but there is a Integration with Test Runners: jest which is up-to-date
this depends on what you want from your tests:
i personally recommend to use a global instance if possible, because it is way faster for the test than spinning up and cleaning up instance after each test / test suite and also currently it may fail (randomly?) if tests are run parallel because ports may become used after being checked for being free also, there is the possibility of just using different databases for each test suite / test and/or running a |
Beta Was this translation helpful? Give feedback.
i dont quite know you specifications, but there is Integration with Test Runners: Mocha / chai, which may be outdated, because we (maintainers) dont really use mocha / chai anymore, but there is a Integration with Test Runners: jest which is up-to-date
this depends on what you want from your tests:
i pers…