diff --git a/test/errors.test.js b/test/errors.test.js index 989dad6..9d519f5 100644 --- a/test/errors.test.js +++ b/test/errors.test.js @@ -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) @@ -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) @@ -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) @@ -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)