dt-app
Version:
The Dynatrace App Toolkit is a tool you can use from your command line to create, develop, and deploy apps on your Dynatrace environment.
18 lines (15 loc) • 579 B
text/typescript
const fetchMock = jest.fn();
globalThis.fetch = fetchMock;
import functionName from './function-name';
describe('function-name', () => {
it('should return an object with a message property', async () => {
// An example of how to overwrite the implementation of fetch within a test.
fetchMock.mockImplementationOnce(() => {
throw new Error('fetch should not be called in this function');
});
const result = await functionName();
expect(result).toEqual('Hello world');
expect(fetchMock).not.toHaveBeenCalled();
expect.assertions(2);
});
});