From 27017925161c2abd63764c3615266e9a2bacd79f Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Sat, 28 Jan 2023 11:24:06 -0800 Subject: [PATCH] Update more flakey API support checks (#45373) x-ref: https://github.com/vercel/next.js/actions/runs/4033048662/jobs/6933337411 --- .../api-support/test/index.test.js | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/test/integration/api-support/test/index.test.js b/test/integration/api-support/test/index.test.js index 4e66350ac1..56fb54a758 100644 --- a/test/integration/api-support/test/index.test.js +++ b/test/integration/api-support/test/index.test.js @@ -308,16 +308,24 @@ function runTests(dev = false) { it('should show friendly error for invalid redirect', async () => { await fetchViaHTTP(appPort, '/api/redirect-error', null, {}) - expect(stderr).toContain( - `Invalid redirect arguments. Please use a single argument URL, e.g. res.redirect('/destination') or use a status code and URL, e.g. res.redirect(307, '/destination').` - ) + + await check(() => { + expect(stderr).toContain( + `Invalid redirect arguments. Please use a single argument URL, e.g. res.redirect('/destination') or use a status code and URL, e.g. res.redirect(307, '/destination').` + ) + return 'yes' + }, 'yes') }) it('should show friendly error in case of passing null as first argument redirect', async () => { await fetchViaHTTP(appPort, '/api/redirect-null', null, {}) - expect(stderr).toContain( - `Invalid redirect arguments. Please use a single argument URL, e.g. res.redirect('/destination') or use a status code and URL, e.g. res.redirect(307, '/destination').` - ) + + check(() => { + expect(stderr).toContain( + `Invalid redirect arguments. Please use a single argument URL, e.g. res.redirect('/destination') or use a status code and URL, e.g. res.redirect(307, '/destination').` + ) + return 'yes' + }, 'yes') }) it('should redirect with status code 307', async () => { @@ -547,10 +555,14 @@ function runTests(dev = false) { it('should show false positive warning if not using externalResolver flag', async () => { const apiURL = '/api/external-resolver-false-positive' const req = await fetchViaHTTP(appPort, apiURL) - expect(stderr).toContain( - `API resolved without sending a response for ${apiURL}, this may result in stalled requests.` - ) expect(await req.text()).toBe('hello world') + + check(() => { + expect(stderr).toContain( + `API resolved without sending a response for ${apiURL}, this may result in stalled requests.` + ) + return 'yes' + }, 'yes') }) it('should not show warning if using externalResolver flag', async () => {