I have followed the medium guide : https://medium.com/@tehvicke/integration-and-unit-testing-with-jest-in-nodejs-and-mongoose-bd41c61c9fbc trying to develop a test suite. My code is exactly like his but I am having the TypeError: Tournament is not a constructor
I put some code, so you can see what I am trying to do.
TournamentService.js
const createTournament = (Tournament) => (tournamentObj) => {
  const {name, creator} = tournamentObj;
  const newTournament = new Tournament({name, creator});
  return newTournament.save();
};
TournamentService.test.js
const TournamentService = require("../TournamentService");
const sinon = require("sinon");
describe("create Tournament test", () => {
  it("creates a tournament", () => {
    const save = sinon.spy();
    console.log("save ", save);
    let name;
    let creator;
    const MockTournamentModel = (tournamentObject) => {
      name = tournamentObject.name;
      creator = tournamentObject.creator;
      return {
        ...tournamentObject,
        save,
      };
    };
    const tournamentService = TournamentService(MockTournamentModel);
    const fintoElemento = {
      name: "Test tournament",
      creator: "jest",
    };
    tournamentService.createTournament(fintoElemento);
    const expected = true;
    const actual = save.calledOnce;
    expect(actual).toEqual(expected);
    expect(name).toEqual("Test tournament");
  });
});