Issue Tracker Project - Functional Test issue

Hi guys

I wondered whether any of you have run into this problem,

My issue is that the .env variables are read correctly when the app is actually running, but when I run the functional tests the .env variables come back as undefined and I get the error MongoError: Authentication failed.

I’m using mongoose on this one,


I have searched the internet for answers for hours and nothing has worked so far,

Thanks in advance,


Hey there~!

Are you seeing data written to your Mongo DB? I tried running your project and got connection errors.

Hi Nicholas, thanks for taking a look at this,

Yes I can see your post in mongo db so that worked,

When I’m signed in to there’s no error, although when I am not signed in I can see the authentication error as well,

The app seems to read the environment variables fine when the app is running though when I run the functional tests they come back as undefined so the tests fail,


To run the tests btw just run ‘npm test’ I’ve set the script

Found the solution… set NODE_ENV=test in the .env file, this instruction is contained in the README file.

This way tests run automatically when the app runs and the db connection is successful.