1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
import $ from 'jquery'; import { ajax_get, ajax_get_statistics } from "../MonitoringUtils"; $.ajax = jest.fn().mockImplementation(() => { const fakeResponse = { data: { id: 1, name: "All", value: "Dummy Data" } }; return Promise.resolve(fakeResponse); }); test('ajax_get return ok', () => { ajax_get().then(response => { expect(response.data.id).toBe(1); }); });