Skip to content

Commit

Permalink
node v20+ throws a different error message for unparsable json - fix …
Browse files Browse the repository at this point in the history
…tests
  • Loading branch information
n0v1 committed May 15, 2024
1 parent 4a9943b commit 6e696dd
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions test/errors.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,8 @@ test('should handle an error in the handler in res stream app', async t => {
t.truthy(errMsg1)
t.truthy(errMsg2)
t.true(endCalled)
t.true(errMsg1.indexOf('Unexpected token') >= 0)
t.true(errMsg2.indexOf('Unexpected token') >= 0)
t.true(/Unexpected.+JSON at position/.test(errMsg1))
t.true(/Unexpected.+JSON at position/.test(errMsg2))
t.truthy(errCtx)
t.truthy(errCtx.call)
t.truthy(errCtx.req)
Expand Down Expand Up @@ -523,8 +523,8 @@ test('should handle an error in the handler in req stream app', async t => {

t.truthy(error)
t.truthy(error.message)
t.true(errMsg1.indexOf('Unexpected token') >= 0)
t.true(error.message.indexOf('Unexpected token') >= 0)
t.true(/Unexpected.+JSON at position/.test(errMsg1))
t.true(/Unexpected.+JSON at position/.test(error.message))
t.truthy(errCtx)
t.truthy(errCtx.call)
t.truthy(errCtx.req)
Expand Down Expand Up @@ -680,8 +680,8 @@ test('should handle an error in the handler of duplex call', async t => {
t.truthy(errMsg1)
t.truthy(errMsg2)
t.true(endCalled)
t.true(errMsg1.indexOf('Unexpected token') >= 0)
t.true(errMsg2.indexOf('Unexpected token') >= 0)
t.true(/Unexpected.+JSON at position/.test(errMsg1))
t.true(/Unexpected.+JSON at position/.test(errMsg2))
t.truthy(errCtx)
t.truthy(errCtx.call)
t.truthy(errCtx.req)
Expand Down Expand Up @@ -772,8 +772,8 @@ test('should handle an error in the handler of duplex call that returns a promis
t.truthy(errMsg1)
t.truthy(errMsg2)
t.true(endCalled)
t.true(errMsg1.indexOf('Unexpected token') >= 0)
t.true(errMsg2.indexOf('Unexpected token') >= 0)
t.true(/Unexpected.+JSON at position/.test(errMsg1))
t.true(/Unexpected.+JSON at position/.test(errMsg2))
t.truthy(errCtx)
t.truthy(errCtx.call)
t.truthy(errCtx.req)
Expand Down

0 comments on commit 6e696dd

Please sign in to comment.