| 11 | const detoxGlobalSetup: () => Promise<void> = require('detox/runners/jest/globalSetup.js'); |
| 12 | |
| 13 | function findProjectRoot(...startDirs: string[]) { |
| 14 | for (const startDir of startDirs) { |
| 15 | let currentDir = path.resolve(startDir); |
| 16 | while (true) { |
| 17 | const hasMarkers = |
| 18 | fs.existsSync(path.join(currentDir, 'package.json')) && |
| 19 | fs.existsSync( |
| 20 | path.join( |
| 21 | currentDir, |
| 22 | 'scripts/run-prepare-local-update-artifacts.js', |
| 23 | ), |
| 24 | ) && |
| 25 | fs.existsSync(path.join(currentDir, 'scripts/local-e2e-server.ts')); |
| 26 | |
| 27 | if (hasMarkers) { |
| 28 | return currentDir; |
| 29 | } |
| 30 | |
| 31 | const parentDir = path.dirname(currentDir); |
| 32 | if (parentDir === currentDir) { |
| 33 | break; |
| 34 | } |
| 35 | currentDir = parentDir; |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | throw new Error('Unable to resolve the e2etest project root.'); |
| 40 | } |
| 41 | |
| 42 | const projectRoot = findProjectRoot(process.cwd(), __dirname); |
| 43 | const packageJson = JSON.parse( |