diff --git a/test/integration/api-support/test/index.test.js b/test/integration/api-support/test/index.test.js index efc1e99f603d7..a803bbdaceb26 100644 --- a/test/integration/api-support/test/index.test.js +++ b/test/integration/api-support/test/index.test.js @@ -118,30 +118,16 @@ function runTests(dev = false) { }) it('should return error exceeded body limit', async () => { - let res - let error - - try { - res = await fetchViaHTTP(appPort, '/api/parse', null, { - method: 'POST', - headers: { - 'Content-Type': 'application/json; charset=utf-8', - }, - body: JSON.stringify(json), - }) - } catch (err) { - error = err - } + const data = await fetchViaHTTP(appPort, '/api/parse', null, { + method: 'POST', + headers: { + 'Content-Type': 'application/json; charset=utf-8', + }, + body: JSON.stringify(json), + }) - if (error) { - // This is a temporary workaround for testing since node doesn't handle - // closed connections when POSTing data to an endpoint correctly - // https://github.com/nodejs/node/issues/12339 - expect(error.code).toBe('EPIPE') - } else { - expect(res.status).toEqual(413) - expect(res.statusText).toEqual('Body exceeded 1mb limit') - } + expect(data.status).toEqual(413) + expect(data.statusText).toEqual('Body exceeded 1mb limit') }) it('should parse bigger body then 1mb', async () => {