Test timed out while creating and saving a db item

Tell us what’s happening:
Repeatedly failing in the ‘Create and Save a Record of a Model’ challenge as running the test keeps stating that the test timed out.

// running tests
Creating and saving a db item should succeed (Test timed out)
// tests completed

I have implemented code to check whether the MongoDB connection is successful and there is no issue there. I have also ensured that network access from anywhere is enabled on the database.

mongoose.connect(process.env.MONGO_URI)
      .then(() => {
         console.log('Database connection successful')
       })
       .catch(err => {
         console.error('Database connection error')
       })

let personSchema = new mongoose.Schema({
  name: {
    type: String,
    required: true
  },
  age: Number,
  favoriteFoods: [String]
})

let Person = mongoose.model("Person", personSchema);

const createAndSavePerson = (done) => {
  let newPerson = new Person({
    name: "Brandon",
    age: 23,
    favoriteFoods: ['cheesecake', 'pizza', 'burgers']
  });
  newPerson.save = (err, data) => {
    if(err){
      console.log(err);
      done(err);
    } else{
      done(null, data);
    }
  }
};

Your project link(s)

solution: boilerplate-mongomongoose - Replit

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.114 Safari/537.36

Challenge: Create and Save a Record of a Model

Link to the challenge:

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