Skip to content

Instantly share code, notes, and snippets.

@fabriciofmsilva
Last active August 15, 2019 21:51
Show Gist options
  • Save fabriciofmsilva/42b0e28081ba6f191fe160e8d2aff1a8 to your computer and use it in GitHub Desktop.
Save fabriciofmsilva/42b0e28081ba6f191fe160e8d2aff1a8 to your computer and use it in GitHub Desktop.
Moment Mock
import { fn as momentProto } from 'moment';
const MOCK_TODAY = '2019-08-14';
const sandbox = sinon.sandbox.create();
before(() => {
sandbox.stub(momentProto, 'toISOString');
momentProto.toISOString.withArgs().returns(MOCK_TODAY);
});
after(() => {
sandbox.restore();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment