Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('ExtendedError', async () => {
const e = new ExtendedError({
user: {
message: 'some message',
email: 'some email address',
},
});
await failureLogger()(e);
expect(logger.error.mock.calls).toHaveLength(1);
const loggedError = logger.error.mock.calls[0][0];
expect(loggedError.user).toBeUndefined();
});
it('fetch response error with status', async () => {
const headers = new Headers();
headers.append('content-type', 'text/plain; charset=utf-8');
const errorResponse500 = new Response('500 Internal Server Error', {
status: 500,
headers,
});
await failureLogger()(errorResponse500);
expect(logger.error.mock.calls).toHaveLength(1);
assertErrorLog(logger.error.mock.calls[0][0]);
const errorResponse404 = new Response('404 Not Found', {
status: 404,
headers,
});
await failureLogger()(errorResponse404);
expect(logger.error.mock.calls).toHaveLength(1);
expect(logger.warn.mock.calls).toHaveLength(1);
assertErrorLog(logger.warn.mock.calls[0][0]);
});