From e167e7fb64b010e0e5c6b0aec7019e94cef45ac5 Mon Sep 17 00:00:00 2001 From: Zack Tanner <1939140+ztanner@users.noreply.github.com> Date: Tue, 11 Jun 2024 15:41:37 -0700 Subject: [PATCH] fix app-custom-routes deploy test (#66773) - `next.cliOutput` will only refer to build time logs, so this particular assertion won't work - Drive-by refactor for it to use `retry` instead of `check` Verified this passes when deployed --- test/deploy-tests-manifest.json | 1 - .../app-routes/app-custom-routes.test.ts | 25 ++++++++++--------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/test/deploy-tests-manifest.json b/test/deploy-tests-manifest.json index 1d1a13ee8c4b4..132772f6c2d10 100644 --- a/test/deploy-tests-manifest.json +++ b/test/deploy-tests-manifest.json @@ -7,7 +7,6 @@ "test/production/**/*.test.{t,j}s{,x}" ], "exclude": [ - "test/e2e/app-dir/app-routes/app-custom-routes.test.ts", "test/e2e/app-dir/next-after-app/index.test.ts", "test/e2e/app-dir/scss/nm-module-nested/nm-module-nested.test.ts", "test/e2e/cancel-request/stream-cancel.test.ts", diff --git a/test/e2e/app-dir/app-routes/app-custom-routes.test.ts b/test/e2e/app-dir/app-routes/app-custom-routes.test.ts index 2fd595c6f7a59..1859ffbd9b26a 100644 --- a/test/e2e/app-dir/app-routes/app-custom-routes.test.ts +++ b/test/e2e/app-dir/app-routes/app-custom-routes.test.ts @@ -1,5 +1,5 @@ import { nextTestSetup } from 'e2e-utils' -import { check, waitFor } from 'next-test-utils' +import { check, waitFor, retry } from 'next-test-utils' import { Readable } from 'stream' import { @@ -679,18 +679,19 @@ describe('app-custom-routes', () => { }) } - describe('no response returned', () => { - it('should print an error when no response is returned', async () => { - await next.fetch(basePath + '/no-response', { method: 'POST' }) - - await check(() => { - expect(next.cliOutput).toMatch( - /No response is returned from route handler '.+\/route\.ts'\. Ensure you return a `Response` or a `NextResponse` in all branches of your handler\./ - ) - return 'yes' - }, 'yes') + // This test is skipped in deploy mode because `next.cliOutput` will only contain build-time logs. + if (!isNextDeploy) { + describe('no response returned', () => { + it('should print an error when no response is returned', async () => { + await next.fetch(basePath + '/no-response', { method: 'POST' }) + await retry(() => { + expect(next.cliOutput).toMatch( + /No response is returned from route handler '.+\/route\.ts'\. Ensure you return a `Response` or a `NextResponse` in all branches of your handler\./ + ) + }) + }) }) - }) + } describe('no bundle error', () => { it('should not print bundling warning about React', async () => {