|
1 | | -import { SentryError } from '@sentry/utils'; |
2 | 1 | // NOTE: I have no idea how to fix this right now, and don't want to waste more time, as it builds just fine — Kamil |
3 | 2 | // eslint-disable-next-line import/no-unresolved |
4 | 3 | import { Callback, Handler } from 'aws-lambda'; |
@@ -178,44 +177,6 @@ describe('AWSLambda', () => { |
178 | 177 | expect(Sentry.captureException).toHaveBeenNthCalledWith(2, error2); |
179 | 178 | expect(Sentry.captureException).toBeCalledTimes(2); |
180 | 179 | }); |
181 | | - |
182 | | - test('ignoreSentryErrors - with successful handler', async () => { |
183 | | - const sentryError = new SentryError('HTTP Error (429)'); |
184 | | - jest.spyOn(Sentry, 'flush').mockRejectedValueOnce(sentryError); |
185 | | - |
186 | | - const handledError = new Error('handled error, and we want to monitor it'); |
187 | | - const expectedSuccessStatus = { status: 'success', reason: 'we handled error, so success' }; |
188 | | - const handler = () => { |
189 | | - Sentry.captureException(handledError); |
190 | | - return Promise.resolve(expectedSuccessStatus); |
191 | | - }; |
192 | | - const wrappedHandlerWithoutIgnoringSentryErrors = wrapHandler(handler, { ignoreSentryErrors: false }); |
193 | | - const wrappedHandlerWithIgnoringSentryErrors = wrapHandler(handler, { ignoreSentryErrors: true }); |
194 | | - |
195 | | - await expect(wrappedHandlerWithoutIgnoringSentryErrors(fakeEvent, fakeContext, fakeCallback)).rejects.toThrow( |
196 | | - sentryError, |
197 | | - ); |
198 | | - await expect(wrappedHandlerWithIgnoringSentryErrors(fakeEvent, fakeContext, fakeCallback)).resolves.toBe( |
199 | | - expectedSuccessStatus, |
200 | | - ); |
201 | | - }); |
202 | | - |
203 | | - test('ignoreSentryErrors - with failed handler', async () => { |
204 | | - const sentryError = new SentryError('HTTP Error (429)'); |
205 | | - jest.spyOn(Sentry, 'flush').mockRejectedValueOnce(sentryError); |
206 | | - |
207 | | - const criticalUnhandledError = new Error('critical unhandled error '); |
208 | | - const handler = () => Promise.reject(criticalUnhandledError); |
209 | | - const wrappedHandlerWithoutIgnoringSentryErrors = wrapHandler(handler, { ignoreSentryErrors: false }); |
210 | | - const wrappedHandlerWithIgnoringSentryErrors = wrapHandler(handler, { ignoreSentryErrors: true }); |
211 | | - |
212 | | - await expect(wrappedHandlerWithoutIgnoringSentryErrors(fakeEvent, fakeContext, fakeCallback)).rejects.toThrow( |
213 | | - sentryError, |
214 | | - ); |
215 | | - await expect(wrappedHandlerWithIgnoringSentryErrors(fakeEvent, fakeContext, fakeCallback)).rejects.toThrow( |
216 | | - criticalUnhandledError, |
217 | | - ); |
218 | | - }); |
219 | 180 | }); |
220 | 181 |
|
221 | 182 | describe('wrapHandler() on sync handler', () => { |
|
0 commit comments