title: Issue with testing async class method with Jest
body: <p>I have a class that has an async constructor called init(). I am trying to create a test for it, but I am having some issues. The code works fine, but the tests gives the following error:</p>
  
  <blockquote>
    <p>Timeout - Async callback was not invoked within the 5000ms timeout
    specified by jest.setTimeout.Timeout - Async callback was not invoked
    within the 5000ms timeout specified by jest.setTimeout.Error:</p>
  </blockquote>
  
  <p>This is the class:</p>
  
  <pre><code>const { Settings } = require("../models/settings");
  const moment = require("moment");
  
  class Config {
  
    async init() {
  
      let settings = await Settings.findOne(); // This looks like the line where it gets stuck
      if (!settings) settings = await createDefaultConfig();
  
      this.lastBookableDay = settings.lastBookableDay;
      this.slotDuration = settings.slotDuration;
      this.interval = settings.interval;
      this.expireOffset = settings.expireOffset;
      this.cancelationNotice = settings.cancelationNotice;
      this.week = settings.week;
    }
  }
  
  async function createDefaultConfig() {
    const settings = await Settings.find();
    let last = moment().format("YYYY-MM-DD");
    last = moment(last).add(10, "day").unix();
    if (settings.length &lt; 1) {
      const newSettings = new Settings({
        lastBookableDay: last,
        slotDuration: 50,
        interval: 10,
        expireOffset: 60,
        cancelationNotice: 24,
        week: [...new Array(7)].map(() =&gt;
          ({ startHours: 10, startMinutes: 0, slotNumber: 5, off: false }))
      });
      await newSettings.save();
    }
  }
  
  module.exports = Config;
  </code></pre>
  
  <p>I have other tests that access the db with no issues.</p>
  
  <p>This is the code of the failing test (for simplicity there is no cleanup of the db): </p>
  
  <pre><code>const Settings = require("./settings.js");
  
  describe("Settings class", () =&gt; {
  
    it("should init settings instance", async () =&gt; {
  
      const settings = new Settings();
      await settings.init();
  
      console.log(settings)
      expect(settings.slotDuration).toBe(50);
    })
  
  });
  </code></pre>
  
  <p>Can someone point me out what I'm doing wrong please? Thanks.</p>