intro-mongo-db
intro-mongo-db copied to clipboard
tests passing without entering data
hey there! I'm having issues with getting tests to pass with the models exercises.
Steps taken
click to see my steps
git clone urlnpm install- navigate to the exercises/models directory and run this
npm test exercises/models/__test__/- tests pass even though I did not enter code for tests
on the connect.js file I entered this
const mongoose = require('mongoose')
mongoose.Promise = global.Promise
const connect = () => {
return mongoose.connect('mongodb://localhost:27017/usersDatabase')
}
module.exports = connect
If you use yarn test, instead of npm, the tests run as expected.
If you use yarn test, instead of npm, the tests run as expected.
does this mean I'd have to do yarn install (instead of npm install)? And use yarn throughout the project? Or only use yarn to run the tests?
I'm just getting my feet wet with yarn and did npm install (mostly out of habit). I would assume that yarn would still install the same packages and package dependencies. So for this I'm just using yarn to run the tests.
I met similar problems running tests for exercise. Some tests passed even before I write a code with an error message "server instance pool was destroyed". I modified afterEach call in testconfig.js as below and now it works fine.
afterEach(async done => {
await mongoose.disconnect()
return done()
}
NPM is for sure conflicting with something when i used YARN everything worked flawlessly
to avoid unexpected behaviour use YARN
Thanks @kimdho, your solution worked for me using NPM
You forgot the 'e' :P
On Thu, Apr 16, 2020, 4:10 PM agilmore [email protected] wrote:
Thanks @kimdho https://github.com/kimdho, your solution worked for me using NPM
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/FrontendMasters/intro-mongo-db/issues/9#issuecomment-614869257, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJOZADJP6WG3RHGXU2QRLXLRM5Q2PANCNFSM4H3LZ4PA .
@matacabras @kimdho 🤣