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.
22 lines (18 loc) • 659 B
text/typescript
/**
* @jest-environment @dynatrace/runtime-simulator/lib/test-environment
*/
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);
});
});