title: How to test a method inside a static method with Jest?
body: <p>I have a class with a factory method like this:</p>
  <pre><code>import {AggregateRoot} from '@nestjs/cqrs'
  
  class MyClass extends AggregateRoot {
    static create(condition: boolean): MyClass {
  
      const newMyClass = new MyClass()
  
      if (condition) {
        newMyClass.apply(new DomainEvent())
      }
  
      return newMyClass
    }
  }
  </code></pre>
  <p>I want to test if the method <code>doSomething()</code> is called during the creation of the new object.</p>
  <p>I don't know how to mock it, because the object will be created using the factory method. The method I want to test is inside the object, so I can't use it before the object is created.</p>