Can I test the MongoDB challenges Locally?

In short, I would like to know if I can test the mongoose challenges locally without pasting the URL.

Like many others, I’m seeing time-out issues when I’m trying to paste the Repl.it URL to the solver at FCC. Thus I tested the previous challenges locally by forking the github repository and starting the server with node server.js. The changes were always quite visible at localhost:3000 in the browser.

However, with the MongoDB challenges I’m not quite sure how to double-check if it works. For example, I tried localhost:3000/is-mongoose-ok because I see that this is requested in server.js, but it says “not found”. Do I have a thinking mistake , and it is not possible to check it like this, or is my program not working?

This is from server.js:

router.get("/is-mongoose-ok", function (req, res) {
  if (mongoose) {
    res.json({ isMongooseOk: !!mongoose.connection.readyState });
  } else {
    res.json({ isMongooseOk: false });
  }
});

However, I’m checking the connection in “App.js” and it prints out “Connected Database Successfully” on the terminal command line, so I guess the database connection is not the problem:

const connection = mongoose.connection;
connection.once('open', () => {
  console.log("Connected Database Successfully");
})

Your browser information:

User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:86.0) Gecko/20100101 Firefox/86.0.

Challenge: Install and Set Up Mongoose

Link to the challenge:

Welcome, miatemma.

Specifically, the testing endpoint is /_api/is-mongoose-ok, because of this line:

app.use("/_api", enableCORS, router);

It is quite possible, and the devs do it all the time.

The way I see it, you have these options, if you are unhappy with the Replit experience:

  1. Use another service (e.g. Glitch, CodeSandbox)
  2. Self-host (e.g. Heroku)
  3. Run the server locally, as you are, but submit your http://localhost:3000 link (does not work for the projects, but should for the challenges)
  4. Run freeCodeCamp locally (Contribution Guidelines | freeCodeCamp.org), and test with your own instance of fCC, where you can see/control the tests.

Here are where the tests are located: https://github.com/freeCodeCamp/freeCodeCamp/blob/main/curriculum/challenges/english/05-apis-and-microservices/mongodb-and-mongoose/install-and-set-up-mongoose.md (for this challenge)

Hope this helps

1 Like

Hi, thank you! This perfectly solves my question and even more. :slight_smile:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.