1+ import  {  trace  }  from  'next/dist/trace' 
2+ import  {  createNextInstall  }  from  '../../lib/create-next-install' 
13import  { 
24  EXAMPLE_PATH , 
35  EXAMPLE_REPO , 
@@ -10,12 +12,23 @@ import {
1012}  from  './utils' 
1113
1214describe ( 'create-next-app --example' ,  ( )  =>  { 
15+   let  nextInstall : Awaited < ReturnType < typeof  createNextInstall > > 
16+   beforeAll ( async  ( )  =>  { 
17+     nextInstall  =  await  createNextInstall ( { 
18+       parentSpan : trace ( 'test' ) , 
19+       keepRepoDir : Boolean ( process . env . NEXT_TEST_SKIP_CLEANUP ) , 
20+     } ) 
21+   } ) 
1322  it ( 'should create on valid Next.js example name' ,  async  ( )  =>  { 
1423    await  useTempDir ( async  ( cwd )  =>  { 
1524      const  projectName  =  'valid-example' 
16-       const  res  =  await  run ( [ projectName ,  '--example' ,  'basic-css' ] ,  { 
17-         cwd, 
18-       } ) 
25+       const  res  =  await  run ( 
26+         [ projectName ,  '--example' ,  'basic-css' ] , 
27+         nextInstall . installDir , 
28+         { 
29+           cwd, 
30+         } 
31+       ) 
1932      expect ( res . exitCode ) . toBe ( 0 ) 
2033      projectFilesShouldExist ( { 
2134        cwd, 
@@ -34,9 +47,13 @@ describe('create-next-app --example', () => {
3447  it ( 'should create with GitHub URL' ,  async  ( )  =>  { 
3548    await  useTempDir ( async  ( cwd )  =>  { 
3649      const  projectName  =  'github-url' 
37-       const  res  =  await  run ( [ projectName ,  '--example' ,  FULL_EXAMPLE_PATH ] ,  { 
38-         cwd, 
39-       } ) 
50+       const  res  =  await  run ( 
51+         [ projectName ,  '--example' ,  FULL_EXAMPLE_PATH ] , 
52+         nextInstall . installDir , 
53+         { 
54+           cwd, 
55+         } 
56+       ) 
4057
4158      expect ( res . exitCode ) . toBe ( 0 ) 
4259      projectFilesShouldExist ( { 
@@ -64,6 +81,7 @@ describe('create-next-app --example', () => {
6481          // GH#39665 
6582          'https://github.com/vercel/nextjs-portfolio-starter/' , 
6683        ] , 
84+         nextInstall . installDir , 
6785        { 
6886          cwd, 
6987        } 
@@ -97,6 +115,7 @@ describe('create-next-app --example', () => {
97115          '--example-path' , 
98116          EXAMPLE_PATH , 
99117        ] , 
118+         nextInstall . installDir , 
100119        { 
101120          cwd, 
102121        } 
@@ -131,6 +150,7 @@ describe('create-next-app --example', () => {
131150          '--example-path' , 
132151          EXAMPLE_PATH , 
133152        ] , 
153+         nextInstall . installDir , 
134154        { 
135155          cwd, 
136156        } 
@@ -168,6 +188,7 @@ describe('create-next-app --example', () => {
168188            '__internal-testing-retry' , 
169189            '--import-alias=@/*' , 
170190          ] , 
191+           nextInstall . installDir , 
171192          { 
172193            cwd, 
173194            input : '\n' ,  // 'Yes' to retry 
@@ -199,6 +220,7 @@ describe('create-next-app --example', () => {
199220          'default' , 
200221          '--import-alias=@/*' , 
201222        ] , 
223+         nextInstall . installDir , 
202224        { 
203225          cwd, 
204226        } 
@@ -217,10 +239,14 @@ describe('create-next-app --example', () => {
217239  it ( 'should not create if --example flag value is invalid' ,  async  ( )  =>  { 
218240    await  useTempDir ( async  ( cwd )  =>  { 
219241      const  projectName  =  'invalid-example' 
220-       const  res  =  await  run ( [ projectName ,  '--example' ,  'not a real example' ] ,  { 
221-         cwd, 
222-         reject : false , 
223-       } ) 
242+       const  res  =  await  run ( 
243+         [ projectName ,  '--example' ,  'not a real example' ] , 
244+         nextInstall . installDir , 
245+         { 
246+           cwd, 
247+           reject : false , 
248+         } 
249+       ) 
224250
225251      expect ( res . exitCode ) . toBe ( 1 ) 
226252      projectFilesShouldNotExist ( { 
@@ -244,6 +270,7 @@ describe('create-next-app --example', () => {
244270          '--no-tailwind' , 
245271          '--example' , 
246272        ] , 
273+         nextInstall . installDir , 
247274        { 
248275          cwd, 
249276          reject : false , 
0 commit comments