@@ -15,15 +15,18 @@ import { getPackageManagerCommand } from '@nx/devkit';
1515describe ( 'nx-flutter e2e' , ( ) => {
1616 let projectDirectory : string ;
1717
18- beforeAll ( ( ) => {
19- // Cleanup the test project
20- projectDirectory &&
18+ afterAll ( ( ) => {
19+ if ( projectDirectory ) {
20+ // Cleanup the test project
2121 rmSync ( projectDirectory , {
2222 recursive : true ,
2323 force : true ,
2424 } ) ;
25+ }
26+ } ) ;
2527
26- projectDirectory = createTestProject ( ) ;
28+ beforeAll ( ( ) => {
29+ projectDirectory = createTestProject ( 'test-project-flutter' ) ;
2730
2831 // The plugin has been built and published to a local registry in the jest globalSetup
2932 // Install the plugin built with the latest source code into the test repo
@@ -62,7 +65,10 @@ describe('nx-flutter e2e', () => {
6265
6366 const sep = process . platform === 'win32' ? '\\' : '/' ;
6467 await runNxCommandAsync (
65- `generate @nxrocks/nx-flutter:create ${ appName } --no-interactive`
68+ `generate @nxrocks/nx-flutter:create ${ appName } --no-interactive` ,
69+ {
70+ cwd : projectDirectory ,
71+ }
6672 ) ;
6773
6874 const executors = [
@@ -105,15 +111,22 @@ describe('nx-flutter e2e', () => {
105111 let totalExecutorsTime = 0 ;
106112 for ( const executor of executors ) {
107113 const start = new Date ( ) . getTime ( ) ;
108- const result = await runNxCommandAsync ( `run ${ appName } :${ executor . name } ` ) ;
114+ const result = await runNxCommandAsync (
115+ `run ${ appName } :${ executor . name } ` ,
116+ {
117+ cwd : projectDirectory ,
118+ }
119+ ) ;
109120 const end = new Date ( ) . getTime ( ) ;
110121 console . log ( `${ executor . name } took ${ end - start } ms` ) ;
111122 totalExecutorsTime += end - start ;
112123 expect ( result . stdout ) . toContain ( executor . output ) ;
113124 }
114125 console . log ( `Total executors time: ${ totalExecutorsTime } ms` ) ;
115126
116- expect ( ( ) => checkFilesExist ( `${ appName } /pubspec.yaml` ) ) . not . toThrow ( ) ;
127+ expect ( ( ) =>
128+ checkFilesExist ( `${ projectDirectory } /${ appName } /pubspec.yaml` )
129+ ) . not . toThrow ( ) ;
117130 } , 400000 ) ;
118131
119132 it ( 'should create nx-flutter project with given options' , async ( ) => {
@@ -128,7 +141,10 @@ describe('nx-flutter e2e', () => {
128141 const offline = true ;
129142
130143 await runNxCommandAsync (
131- `generate @nxrocks/nx-flutter:create ${ appName } --org=${ org } --description="${ description } " --androidLanguage=${ androidLanguage } --iosLanguage=${ iosLanguage } --template=${ template } --platforms="${ platforms } " --pub=${ pub } --offline=${ offline } --no-interactive`
144+ `generate @nxrocks/nx-flutter:create ${ appName } --org=${ org } --description="${ description } " --androidLanguage=${ androidLanguage } --iosLanguage=${ iosLanguage } --template=${ template } --platforms="${ platforms } " --pub=${ pub } --offline=${ offline } --no-interactive` ,
145+ {
146+ cwd : projectDirectory ,
147+ }
132148 ) ;
133149
134150 const executors = [
@@ -138,16 +154,21 @@ describe('nx-flutter e2e', () => {
138154 ] ;
139155
140156 for ( const executor of executors ) {
141- const result = await runNxCommandAsync ( `run ${ appName } :${ executor . name } ` ) ;
157+ const result = await runNxCommandAsync (
158+ `run ${ appName } :${ executor . name } ` ,
159+ {
160+ cwd : projectDirectory ,
161+ }
162+ ) ;
142163 expect ( result . stdout ) . toContain ( executor . output ) ;
143164 }
144165
145166 expect ( ( ) =>
146167 checkFilesExist (
147- `${ appName } /pubspec.yaml` ,
148- `${ appName } /android/build.gradle` ,
149- `${ appName } /ios/Runner.xcodeproj` ,
150- `${ appName } /android/app/src/main/java/com/tinesoft/${ appName . replaceAll (
168+ `${ projectDirectory } / ${ appName } /pubspec.yaml` ,
169+ `${ projectDirectory } / ${ appName } /android/build.gradle` ,
170+ `${ projectDirectory } / ${ appName } /ios/Runner.xcodeproj` ,
171+ `${ projectDirectory } / ${ appName } /android/app/src/main/java/com/tinesoft/${ appName . replaceAll (
151172 '-' ,
152173 '_'
153174 ) } /MainActivity.java`
@@ -160,10 +181,13 @@ describe('nx-flutter e2e', () => {
160181 const appName = uniq ( 'nx-flutter-' ) ;
161182
162183 await runNxCommandAsync (
163- `generate @nxrocks/nx-flutter:new --directory subdir/${ appName } --no-interactive`
184+ `generate @nxrocks/nx-flutter:new --directory subdir/${ appName } --no-interactive` ,
185+ {
186+ cwd : projectDirectory ,
187+ }
164188 ) ;
165189 expect ( ( ) =>
166- checkFilesExist ( `subdir/${ appName } /pubspec.yaml` )
190+ checkFilesExist ( `${ projectDirectory } / subdir/${ appName } /pubspec.yaml` )
167191 ) . not . toThrow ( ) ;
168192 } , 200000 ) ;
169193 } ) ;
@@ -173,9 +197,12 @@ describe('nx-flutter e2e', () => {
173197 const appName = uniq ( 'nx-flutter-' ) ;
174198
175199 await runNxCommandAsync (
176- `generate @nxrocks/nx-flutter:create ${ appName } --tags e2etag,e2ePackage --no-interactive`
200+ `generate @nxrocks/nx-flutter:create ${ appName } --tags e2etag,e2ePackage --no-interactive` ,
201+ {
202+ cwd : projectDirectory ,
203+ }
177204 ) ;
178- const project = readJson ( `${ appName } /project.json` ) ;
205+ const project = readJson ( `${ projectDirectory } / ${ appName } /project.json` ) ;
179206 expect ( project . tags ) . toEqual ( [ 'e2etag' , 'e2ePackage' ] ) ;
180207 } , 200000 ) ;
181208 } ) ;
0 commit comments