Issues in Integration testing of node course

Hi,
Please assist. I am getting these errors below. Please note there is no change in the code, it is the same as taught in the course.

(node:2311) [MONGODB DRIVER] Warning: Current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
(Use node --trace-warnings ... to show where the warning was created)
FAIL tests/integration/genres.test.js
api/genres
GET/
✕ should return all the genres (3365 ms)

● api/genres › GET/ › should return all the genres

connect ECONNREFUSED 127.0.0.1:80

according to the error message you need to pass option { useUnifiedTopology: true } in mongoDB constructor connection

I have done that, but it is not working. Can you please share the snippet of the code if possible?

here is a piece of my code for testing to get all the genres

describe("GET /", () => {
    it("should return all genres", async () => {
      await Genres.insertMany([{ name: "genre1" }, { name: "genre2" }]);
      const genres = await request(server).get("/api/genres");

      expect(genres.status).toBe(200);
      expect(genres.body.length).toBe(2);
      expect(genres.body.some((g) => g.name === "genre1"));
      expect(genres.body.some((g) => g.name === "genre2"));
    });
  });

and for server

describe("/api/genres", () => {
  let server;
  beforeEach(() => {
    server = require("../../index");
  });

  afterEach(async () => {
    await Genres.deleteMany({});
    await server.close();
  });

//........
}

Great, thanks. I’ll check it