title: Stub moment.js constructor with Sinon
body: <p>I am not able to stub the <code>moment</code> constructor when calling it with the <code>format</code> function to return a pre-defined string, here's an example spec that I would like to run with <code>mocha</code>:</p>
  
  <pre><code>it('should stub moment', sinon.test(function() {
    console.log('Real call:', moment());
  
    const formatForTheStub = 'DD-MM-YYYY [at] HH:mm';
    const momentStub = sinon.stub(moment(),'format')
                        .withArgs(formatForTheStub)
                        .returns('FOOBARBAZ');
  
    const dateValueAsString = '2025-06-01T00:00:00Z';
  
    const output = moment(dateValueAsString).format(formatForTheStub);
  
    console.log('Stub output:',output);
    expect(output).to.equal('FOOBARBAZ');
  
  }));
  </code></pre>
  
  <p>I am able to see this output using <code>console.log</code>:</p>
  
  <pre><code>Real call: "1970-01-01T00:00:00.000Z"
  Stub output: 01-06-2025 at 01:00
  </code></pre>
  
  <p>But then the test fails cause <code>01-06-2025 at 01:00 !== 'FOOBARBAZ'</code>
  How can I properly stub that <code>moment(something).format(...)</code> call?</p>