import path from 'path' ; import { spawnScript , runCLI , getTempDirectory , cleanupSync , writeFiles , } from '../jest/helpers' ; const cwd = getTempDirectory ( 'test_different_roots' ) ; beforeAll ( ( ) => { for ( const pkg of [ 'platform-ios' , 'platform-android' ] ) { spawnScript ( 'yarn' , [ 'link' ] , { cwd : path . join ( __dirname , `../packages/${ pkg }` ) , } ) ; } cleanupSync ( cwd ) ; writeFiles ( cwd , { } ) ; runCLI ( cwd , [ 'init' , 'TestProject' ] ) ; const pkgs = [ '@react-native-community/cli-platform-ios' , '@react-native-community/cli-platform-android' , ] ; spawnScript ( 'yarn' , [ 'link' , ... pkgs ] , { cwd : path . join ( cwd , 'TestProject' ) , } ) ; } ) ; afterAll ( ( ) => { cleanupSync ( cwd ) ; } ) ; test ( 'works when Gradle is run outside of the project hierarchy' , ( ) => { /**
     * Location of Android project
     */ const androidProjectRoot = path . join ( cwd , 'TestProject/android' ) ; const gradleWrapper = path . join ( androidProjectRoot , 'gradlew' ) ; const { stdout } = spawnScript ( gradleWrapper , [ '-p' , androidProjectRoot ] , { cwd : '/' , } ) ; expect ( stdout ) . toContain ( 'BUILD SUCCESSFUL' ) ; } ) ;