intro-mongo-db icon indicating copy to clipboard operation
intro-mongo-db copied to clipboard

tests passing without entering data

Open vital-tech-results opened this issue 6 years ago • 8 comments
trafficstars

hey there! I'm having issues with getting tests to pass with the models exercises.

Steps taken

click to see my steps
  1. git clone url
  2. npm install
  3. navigate to the exercises/models directory and run this
  4. npm test exercises/models/__test__/
  5. 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

vital-tech-results avatar Jun 25 '19 20:06 vital-tech-results

If you use yarn test, instead of npm, the tests run as expected.

zerogravit1 avatar Jul 12 '19 13:07 zerogravit1

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?

vital-tech-results avatar Jul 15 '19 15:07 vital-tech-results

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.

zerogravit1 avatar Jul 15 '19 15:07 zerogravit1

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()
}

kimdhoe avatar Oct 07 '19 10:10 kimdhoe

NPM is for sure conflicting with something when i used YARN everything worked flawlessly

to avoid unexpected behaviour use YARN

Ashish0077 avatar Feb 02 '20 08:02 Ashish0077

Thanks @kimdho, your solution worked for me using NPM

matacabras avatar Apr 16 '20 20:04 matacabras

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 .

kimdho avatar Apr 16 '20 20:04 kimdho

@matacabras @kimdho 🤣

kimdhoe avatar Apr 19 '20 10:04 kimdhoe