| | import { nextTestSetup } from 'e2e-utils' |
| |
|
| | describe('debug-build-paths', () => { |
| | const { next, skipped } = nextTestSetup({ |
| | files: __dirname, |
| | skipDeployment: true, |
| | skipStart: true, |
| | }) |
| |
|
| | if (skipped) return |
| |
|
| | describe('explicit path formats', () => { |
| | it('should build single page with pages/ prefix', async () => { |
| | const buildResult = await next.build({ |
| | args: ['--debug-build-paths', 'pages/foo.tsx'], |
| | }) |
| | expect(buildResult.exitCode).toBe(0) |
| | expect(buildResult.cliOutput).toBeDefined() |
| |
|
| | |
| | expect(buildResult.cliOutput).toContain('Route (pages)') |
| | expect(buildResult.cliOutput).toContain('β /foo') |
| | |
| | expect(buildResult.cliOutput).not.toContain('β /bar') |
| | |
| | expect(buildResult.cliOutput).not.toContain('Route (app)') |
| | }) |
| |
|
| | it('should build multiple pages routes', async () => { |
| | const buildResult = await next.build({ |
| | args: ['--debug-build-paths', 'pages/foo.tsx,pages/bar.tsx'], |
| | }) |
| | expect(buildResult.exitCode).toBe(0) |
| | expect(buildResult.cliOutput).toBeDefined() |
| |
|
| | |
| | expect(buildResult.cliOutput).toContain('Route (pages)') |
| | expect(buildResult.cliOutput).toContain('β /foo') |
| | expect(buildResult.cliOutput).toContain('β /bar') |
| | |
| | expect(buildResult.cliOutput).not.toContain('Route (app)') |
| | }) |
| |
|
| | it('should build dynamic route with literal [slug] path', async () => { |
| | |
| | |
| | const buildResult = await next.build({ |
| | args: ['--debug-build-paths', 'app/blog/[slug]/page.tsx'], |
| | }) |
| | expect(buildResult.exitCode).toBe(0) |
| | expect(buildResult.cliOutput).toBeDefined() |
| |
|
| | |
| | expect(buildResult.cliOutput).toContain('Route (app)') |
| | expect(buildResult.cliOutput).toContain('/blog/[slug]') |
| | |
| | expect(buildResult.cliOutput).not.toMatch(/β \/\n/) |
| | expect(buildResult.cliOutput).not.toContain('β /about') |
| | expect(buildResult.cliOutput).not.toContain('β /dashboard') |
| | |
| | expect(buildResult.cliOutput).not.toContain('Route (pages)') |
| | }) |
| | }) |
| |
|
| | describe('glob pattern matching', () => { |
| | it('should match app and pages routes with glob patterns', async () => { |
| | const buildResult = await next.build({ |
| | args: ['--debug-build-paths', 'pages/*.tsx,app/page.tsx'], |
| | }) |
| | expect(buildResult.exitCode).toBe(0) |
| | expect(buildResult.cliOutput).toBeDefined() |
| |
|
| | |
| | expect(buildResult.cliOutput).toContain('Route (pages)') |
| | expect(buildResult.cliOutput).toContain('β /foo') |
| | expect(buildResult.cliOutput).toContain('β /bar') |
| |
|
| | |
| | expect(buildResult.cliOutput).toContain('Route (app)') |
| | expect(buildResult.cliOutput).toContain('β /') |
| | |
| | expect(buildResult.cliOutput).not.toContain('β /about') |
| | expect(buildResult.cliOutput).not.toContain('β /dashboard') |
| | }) |
| |
|
| | it('should match nested routes with app/blog/**/page.tsx pattern', async () => { |
| | const buildResult = await next.build({ |
| | args: ['--debug-build-paths', 'app/blog/**/page.tsx'], |
| | }) |
| | expect(buildResult.exitCode).toBe(0) |
| | expect(buildResult.cliOutput).toBeDefined() |
| |
|
| | |
| | expect(buildResult.cliOutput).toContain('Route (app)') |
| | expect(buildResult.cliOutput).toContain('/blog/[slug]') |
| | |
| | expect(buildResult.cliOutput).not.toMatch(/β \/\n/) |
| | expect(buildResult.cliOutput).not.toContain('β /about') |
| | expect(buildResult.cliOutput).not.toContain('β /dashboard') |
| | |
| | expect(buildResult.cliOutput).not.toContain('Route (pages)') |
| | }) |
| |
|
| | it('should match hybrid pattern with literal [slug] and glob **', async () => { |
| | |
| | |
| | |
| | const buildResult = await next.build({ |
| | args: ['--debug-build-paths', 'app/blog/[slug]/**/page.tsx'], |
| | }) |
| | expect(buildResult.exitCode).toBe(0) |
| | expect(buildResult.cliOutput).toBeDefined() |
| |
|
| | |
| | expect(buildResult.cliOutput).toContain('Route (app)') |
| | expect(buildResult.cliOutput).toContain('/blog/[slug]') |
| | expect(buildResult.cliOutput).toContain('/blog/[slug]/comments') |
| | |
| | expect(buildResult.cliOutput).not.toMatch(/β \/\n/) |
| | expect(buildResult.cliOutput).not.toContain('β /about') |
| | expect(buildResult.cliOutput).not.toContain('β /dashboard') |
| | |
| | expect(buildResult.cliOutput).not.toContain('Route (pages)') |
| | }) |
| |
|
| | it('should match multiple app routes with explicit patterns', async () => { |
| | const buildResult = await next.build({ |
| | args: [ |
| | '--debug-build-paths', |
| | 'app/page.tsx,app/about/page.tsx,app/dashboard/page.tsx,app/blog/**/page.tsx', |
| | ], |
| | }) |
| | expect(buildResult.exitCode).toBe(0) |
| | expect(buildResult.cliOutput).toBeDefined() |
| |
|
| | |
| | expect(buildResult.cliOutput).toContain('Route (app)') |
| | expect(buildResult.cliOutput).toContain('β /') |
| | expect(buildResult.cliOutput).toContain('β /about') |
| | expect(buildResult.cliOutput).toContain('β /dashboard') |
| | expect(buildResult.cliOutput).toContain('/blog/[slug]') |
| | |
| | expect(buildResult.cliOutput).not.toContain('/with-type-error') |
| | |
| | expect(buildResult.cliOutput).not.toContain('Route (pages)') |
| | }) |
| | }) |
| |
|
| | describe('typechecking with debug-build-paths', () => { |
| | it('should skip typechecking for excluded app routes', async () => { |
| | |
| | const buildResult = await next.build({ |
| | args: ['--debug-build-paths', 'pages/foo.tsx'], |
| | }) |
| | |
| | expect(buildResult.exitCode).toBe(0) |
| | expect(buildResult.cliOutput).toContain('Route (pages)') |
| | expect(buildResult.cliOutput).toContain('β /foo') |
| | |
| | expect(buildResult.cliOutput).not.toContain('Route (app)') |
| | }) |
| |
|
| | it('should fail typechecking when route with type error is included', async () => { |
| | |
| | const buildResult = await next.build({ |
| | args: ['--debug-build-paths', 'app/**/page.tsx'], |
| | }) |
| | |
| | expect(buildResult.exitCode).toBe(1) |
| | expect(buildResult.cliOutput).toContain('Type error') |
| | expect(buildResult.cliOutput).toContain('with-type-error/page.tsx') |
| | }) |
| | }) |
| | }) |
| |
|