Skip to content

Instantly share code, notes, and snippets.

@dejanvasic85
Created July 24, 2020 00:21
Show Gist options
  • Save dejanvasic85/c3e85479de3a75211271712595f9b949 to your computer and use it in GitHub Desktop.
Save dejanvasic85/c3e85479de3a75211271712595f9b949 to your computer and use it in GitHub Desktop.
Jest Typescript mocking function example
import * as dateService from './dateService';
const nowMock = dateService.now as jest.MockedFunction<typeof dateService.now>;
describe('some service', () => {
const mockNow = 'now';
beforeEach(() => {
nowMock.mockReturnedValue(mockNow);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment