Skip to content

Commit

Permalink
Fixed error logger and unstable tests in core
Browse files Browse the repository at this point in the history
  • Loading branch information
lmammino authored and benjifs committed May 21, 2020
1 parent 4aaa816 commit 452bc3a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/core/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ describe('🛵 Middy test suite', () => {
setTimeout(() => {
expect(calls).toBe(1)
endTest()
}, 100)
}, 200)
}

test('onSuccess', (endTest) => {
Expand Down
8 changes: 4 additions & 4 deletions packages/error-logger/__tests__/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const middy = require('../../core')
const errorLogger = require('../')

describe('📦 Middleware Error Logger', (endTest) => {
test('It should log errors and propagate the error', () => {
const logger = jest.fn()
describe('📦 Middleware Error Logger', () => {
test('It should log errors and propagate the error', (endTest) => {
const error = new Error('something bad happened')
const logger = jest.fn()

const handler = middy((event, context, cb) => {
cb(error)
Expand All @@ -17,7 +17,7 @@ describe('📦 Middleware Error Logger', (endTest) => {
handler({}, {}, (err, response) => {
expect(logger).toHaveBeenCalledWith(error)
expect(err).toBe(error)
expect(response).toBe(null)
expect(response).toBeUndefined()
endTest()
})
})
Expand Down
2 changes: 1 addition & 1 deletion packages/error-logger/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = (opts) => {
const options = Object.assign({}, defaults, opts)

return ({
error: (handler, next) => {
onError: (handler, next) => {
if (typeof options.logger === 'function') {
options.logger(handler.error)
}
Expand Down

0 comments on commit 452bc3a

Please sign in to comment.