From 36f78ac990f1f240c218a8f6d70b0bf76cac0c5c Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Fri, 13 Dec 2019 08:26:40 -0500 Subject: [PATCH] Enable Page Symbol For `/_error` --- packages/next/build/utils.ts | 2 +- .../with-error-static/pages/_error.js | 3 +++ .../fixtures/with-error-static/pages/index.js | 3 +++ .../build-output/test/index.test.js | 27 ++++++++++++++++++- 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 test/integration/build-output/fixtures/with-error-static/pages/_error.js create mode 100644 test/integration/build-output/fixtures/with-error-static/pages/index.js diff --git a/packages/next/build/utils.ts b/packages/next/build/utils.ts index 17f761cdc2783..d2873c52e3dac 100644 --- a/packages/next/build/utils.ts +++ b/packages/next/build/utils.ts @@ -104,7 +104,7 @@ export async function printTreeView( messages.push([ `${symbol} ${ - item.startsWith('/_') + item === '/_app' ? ' ' : pageInfo && pageInfo.static ? '○' diff --git a/test/integration/build-output/fixtures/with-error-static/pages/_error.js b/test/integration/build-output/fixtures/with-error-static/pages/_error.js new file mode 100644 index 0000000000000..f9c8e36202ac8 --- /dev/null +++ b/test/integration/build-output/fixtures/with-error-static/pages/_error.js @@ -0,0 +1,3 @@ +export default function Error() { + return

An error has occurred

+} diff --git a/test/integration/build-output/fixtures/with-error-static/pages/index.js b/test/integration/build-output/fixtures/with-error-static/pages/index.js new file mode 100644 index 0000000000000..d2ef69607db99 --- /dev/null +++ b/test/integration/build-output/fixtures/with-error-static/pages/index.js @@ -0,0 +1,3 @@ +export default function() { + return
+} diff --git a/test/integration/build-output/test/index.test.js b/test/integration/build-output/test/index.test.js index 289fa6f370596..72a507a2e200e 100644 --- a/test/integration/build-output/test/index.test.js +++ b/test/integration/build-output/test/index.test.js @@ -72,7 +72,7 @@ describe('Build Output', () => { }) expect(stdout).toMatch(/\/ [ ]* \d{1,} B/) - expect(stdout).toMatch(/\/_error [ ]* \d{1,} B/) + expect(stdout).toMatch(/λ \/_error [ ]* \d{1,} B/) expect(stdout).toMatch(/\+ shared by all [ 0-9.]* kB/) expect(stdout).toMatch(/ runtime\/main\.js [ 0-9.]* kB/) @@ -83,4 +83,29 @@ describe('Build Output', () => { expect(stdout).toContain('○ /') }) }) + + describe('Custom Static Error Output', () => { + const appDir = join(fixturesDir, 'with-error-static') + + beforeAll(async () => { + await remove(join(appDir, '.next')) + }) + + // FIXME: this should be static + xit('should specify /_error as static', async () => { + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toContain('○ /_error') + }) + + // This test is not really correct. + // Remove this when fixed and enable the above one. + it('should specify /_error as lambda even when static', async () => { + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toContain('λ /_error') + }) + }) })