From 0729e2e06871608a77f36417a463d94bed55d91f Mon Sep 17 00:00:00 2001 From: Shu Ding Date: Fri, 9 Dec 2022 19:01:27 +0100 Subject: [PATCH] fix error message --- .../build/analysis/get-page-static-info.ts | 2 +- .../app/app-invalid-runtime/page.js | 3 ++ test/e2e/switchable-runtime/index.test.ts | 28 +++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 test/e2e/switchable-runtime/app/app-invalid-runtime/page.js diff --git a/packages/next/build/analysis/get-page-static-info.ts b/packages/next/build/analysis/get-page-static-info.ts index 98a58a74077c..8e153b7fcbac 100644 --- a/packages/next/build/analysis/get-page-static-info.ts +++ b/packages/next/build/analysis/get-page-static-info.ts @@ -316,7 +316,7 @@ export async function getPageStaticInfo(params: { ) } else { Log.error( - `Provided runtime "${config.runtime}" is not supported. Please leave it empty or choose one of: ${options}` + `Provided runtime "${resolvedRuntime}" is not supported. Please leave it empty or choose one of: ${options}` ) } if (!isDev) { diff --git a/test/e2e/switchable-runtime/app/app-invalid-runtime/page.js b/test/e2e/switchable-runtime/app/app-invalid-runtime/page.js new file mode 100644 index 000000000000..19b95445fbea --- /dev/null +++ b/test/e2e/switchable-runtime/app/app-invalid-runtime/page.js @@ -0,0 +1,3 @@ +export default function Page() { + return

Hello from app

+} diff --git a/test/e2e/switchable-runtime/index.test.ts b/test/e2e/switchable-runtime/index.test.ts index 07b3a0f58d5f..6c5c1e44bf2c 100644 --- a/test/e2e/switchable-runtime/index.test.ts +++ b/test/e2e/switchable-runtime/index.test.ts @@ -469,6 +469,34 @@ describe('Switchable runtime', () => { /Hello from page without errors/ ) }) + + it('should give proper errors for invalid runtime in app dir', async () => { + // Invalid runtime + await next.patchFile( + 'app/app-invalid-runtime/page.js', + ` + export default function Page() { + return

Hello from app

+ } + export const runtime = 'invalid-runtime' + ` + ) + await check( + () => renderViaHTTP(next.url, '/app-invalid-runtime'), + /Hello from app/ + ) + expect(next.cliOutput).toInclude( + 'error - Provided runtime "invalid-runtime" is not supported. Please leave it empty or choose one of:' + ) + + await next.patchFile( + 'app/app-invalid-runtime/page.js', + ` + export default function Page() { + return

Hello from app

+ }` + ) + }) }) } else { describe('Switchable runtime (prod)', () => {