Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nataliemarleny/c9faee1f4f919be671babd6f17317342 to your computer and use it in GitHub Desktop.
Save nataliemarleny/c9faee1f4f919be671babd6f17317342 to your computer and use it in GitHub Desktop.
Injecting Mocks into Functions Example
import * as module from 'module';
jest.mock('service-making-a-http-request', () =>
Object.assign(require.requireActual('service-making-a-http-request'), {
externalService: {
execute: jest
.fn()
// function - 'test label' data
.mockResolvedValueOnce({
body: {
results: [1, 2, 3]
}
})
}
})
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment