MCPcopy
hub / github.com/getsentry/sentry / addMockResponse

Method addMockResponse

static/app/__mocks__/api.tsx:141–166  ·  view source on GitHub ↗
(response: Partial<ResponseType>)

Source from the content-addressed store, hash-verified

139
140 // Returns a jest mock that represents Client.request calls
141 static addMockResponse(response: Partial<ResponseType>) {
142 const mock = jest.fn();
143
144 Client.mockResponses.unshift([
145 {
146 host: '',
147 url: '',
148 status: 200,
149 statusCode: 200,
150 statusText: 'OK',
151 responseText: '',
152 responseJSON: '',
153 body: '',
154 method: 'GET',
155 callCount: 0,
156 match: [],
157 ...response,
158 asyncDelay: response.asyncDelay ?? Client.asyncDelay,
159 headers: response.headers ?? {},
160 getResponseHeader: (key: string) => response.headers?.[key] ?? null,
161 },
162 mock,
163 ]);
164
165 return mock;
166 }
167
168 static findMockResponse(url: string, options: Readonly<ApiNamespace.RequestOptions>) {
169 return Client.mockResponses.find(([response]) => {

Calls 1

fnMethod · 0.80

Tested by 15

mockAuditLogsEndpointFunction · 0.64
renderMockRequestsFunction · 0.64
setUpMocksFunction · 0.64
renderSentryAppDetailsFunction · 0.64
renderMockRequestsFunction · 0.64
renderMockRequestsFunction · 0.64
mockEventsFunction · 0.64
mockEventsStatsFunction · 0.64
errorResponseFunction · 0.64