@@ -62,5 +62,71 @@ describe('debug-build-paths', () => {
6262 expect ( buildResult . cliOutput ) . not . toContain ( '○ /about' )
6363 expect ( buildResult . cliOutput ) . not . toContain ( '○ /dashboard' )
6464 } )
65+
66+ it ( 'should match nested routes with app/blog/**/page.tsx pattern' , async ( ) => {
67+ const buildResult = await next . build ( {
68+ args : [ '--debug-build-paths' , 'app/blog/**/page.tsx' ] ,
69+ } )
70+ expect ( buildResult . exitCode ) . toBe ( 0 )
71+ expect ( buildResult . cliOutput ) . toBeDefined ( )
72+
73+ // Should build the blog route
74+ expect ( buildResult . cliOutput ) . toContain ( 'Route (app)' )
75+ expect ( buildResult . cliOutput ) . toContain ( '/blog/[slug]' )
76+ // Should not build other app routes (check for exact route, not substring)
77+ expect ( buildResult . cliOutput ) . not . toMatch ( / ○ \/ \n / )
78+ expect ( buildResult . cliOutput ) . not . toContain ( '○ /about' )
79+ expect ( buildResult . cliOutput ) . not . toContain ( '○ /dashboard' )
80+ // Should not build pages routes
81+ expect ( buildResult . cliOutput ) . not . toContain ( 'Route (pages)' )
82+ } )
83+
84+ it ( 'should match multiple app routes with explicit patterns' , async ( ) => {
85+ const buildResult = await next . build ( {
86+ args : [
87+ '--debug-build-paths' ,
88+ 'app/page.tsx,app/about/page.tsx,app/dashboard/page.tsx,app/blog/**/page.tsx' ,
89+ ] ,
90+ } )
91+ expect ( buildResult . exitCode ) . toBe ( 0 )
92+ expect ( buildResult . cliOutput ) . toBeDefined ( )
93+
94+ // Should build specified app routes
95+ expect ( buildResult . cliOutput ) . toContain ( 'Route (app)' )
96+ expect ( buildResult . cliOutput ) . toContain ( '○ /' )
97+ expect ( buildResult . cliOutput ) . toContain ( '○ /about' )
98+ expect ( buildResult . cliOutput ) . toContain ( '○ /dashboard' )
99+ expect ( buildResult . cliOutput ) . toContain ( '/blog/[slug]' )
100+ // Should not build routes not specified
101+ expect ( buildResult . cliOutput ) . not . toContain ( '/with-type-error' )
102+ // Should not build pages routes
103+ expect ( buildResult . cliOutput ) . not . toContain ( 'Route (pages)' )
104+ } )
105+ } )
106+
107+ describe ( 'typechecking with debug-build-paths' , ( ) => {
108+ it ( 'should skip typechecking for excluded app routes' , async ( ) => {
109+ // Build only pages routes, excluding app routes with type error
110+ const buildResult = await next . build ( {
111+ args : [ '--debug-build-paths' , 'pages/foo.tsx' ] ,
112+ } )
113+ // Build should succeed because the file with type error is not checked
114+ expect ( buildResult . exitCode ) . toBe ( 0 )
115+ expect ( buildResult . cliOutput ) . toContain ( 'Route (pages)' )
116+ expect ( buildResult . cliOutput ) . toContain ( '○ /foo' )
117+ // Should not include app routes
118+ expect ( buildResult . cliOutput ) . not . toContain ( 'Route (app)' )
119+ } )
120+
121+ it ( 'should fail typechecking when route with type error is included' , async ( ) => {
122+ // Build all app routes including the one with type error
123+ const buildResult = await next . build ( {
124+ args : [ '--debug-build-paths' , 'app/**/page.tsx' ] ,
125+ } )
126+ // Build should fail due to type error in with-type-error/page.tsx
127+ expect ( buildResult . exitCode ) . toBe ( 1 )
128+ expect ( buildResult . cliOutput ) . toContain ( 'Type error' )
129+ expect ( buildResult . cliOutput ) . toContain ( 'with-type-error/page.tsx' )
130+ } )
65131 } )
66132} )
0 commit comments