Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests issue #294

Open
ragavendra opened this issue Jun 12, 2024 · 3 comments
Open

Tests issue #294

ragavendra opened this issue Jun 12, 2024 · 3 comments

Comments

@ragavendra
Copy link

ragavendra commented Jun 12, 2024

First of all, thanks for this template or boilerplate, there is a lot of modules that I learnt about.

When I run npm run test a lot of tests are failing like below, although I am running npm run dev in another instance.

 FAIL  tests/integration/auth.test.js (11.239 s)
  Auth routes
    POST /v1/auth/register
      ✕ should return 201 and successfully register user if request data is ok (683 ms)
      ✕ should return 400 error if email is invalid (105 ms)

Correct me if I am wrong. I can see that this project is not actively maintained? The reason for this is that I am seeing some not supported modules like xss-clean

npx create-nodejs-express-app project-name
Need to install the following packages:
[email protected]
Ok to proceed? (y)

npm warn deprecated [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm warn deprecated [email protected]: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
npm warn deprecated [email protected]: Glob versions prior to v9 are no longer supported
npm warn deprecated [email protected]: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
Downloading files from repo https://github.com/hagopj13/node-express-boilerplate.git

@ragavendra
Copy link
Author

Answering my own question. I was getting the below error when running the tests.

No write concern mode named 'majority-test' found in replica set configuration

I was able to fix it by following this .

Looks like the .env.example needs the MONGODB_URL to be updated like MONGODB_URL=mongodb+srv://mrrabbil:[email protected]/app_todo?retryWrites=true

@daveydee33
Copy link

@ragavendra you included your username and password

@apank
Copy link

apank commented Aug 7, 2024

I was able to fix it by following this .

Looks like the .env.example needs the MONGODB_URL to be updated like

the url in .env.example is referencing a local mongo server

the reason why you were getting that error is because in the config it appends -test to the db name; your mongo uri has query options appended to the end; hence why it's saying majority-test

you do not want tests running on your db with live/real data, plus if you take a look at tests/utils/setupTestDB.js you'll see that before each test it purges all the collections.

also as mentioned above you are sharing your username and password in the connection string you pasted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants