diff --git a/e2e-tests/tests/react-native.test.ts b/e2e-tests/tests/react-native.test.ts index 7f2137b7d..1d387eea6 100644 --- a/e2e-tests/tests/react-native.test.ts +++ b/e2e-tests/tests/react-native.test.ts @@ -6,6 +6,7 @@ import { cleanupGit, checkFileContents, checkIfReactNativeBundles, + checkIfReactNativeReleaseBuilds, revertLocalChanges, startWizardInstance } from '../utils'; @@ -207,4 +208,9 @@ defaults.url=https://sentry.io/`, const bundled = await checkIfReactNativeBundles(projectDir, 'ios'); expect(bundled).toBe(true); }); + + test('android project builds correctly', async () => { + const builds = await checkIfReactNativeReleaseBuilds(projectDir, 'android'); + expect(builds).toBe(true); + }); }); diff --git a/e2e-tests/utils/index.ts b/e2e-tests/utils/index.ts index e53f3612a..802339757 100644 --- a/e2e-tests/utils/index.ts +++ b/e2e-tests/utils/index.ts @@ -68,9 +68,14 @@ export class WizardTestEnv { opts?: { cwd?: string; debug?: boolean; + env?: NodeJS.ProcessEnv; }, ) { - this.taskHandle = spawn(cmd, args, { cwd: opts?.cwd, stdio: 'pipe' }); + if (opts?.env) { + this.taskHandle = spawn(cmd, args, { cwd: opts?.cwd, stdio: 'pipe', env: { ...process.env, ...opts?.env } }); + } else { + this.taskHandle = spawn(cmd, args, { cwd: opts?.cwd, stdio: 'pipe' }); + } if (opts?.debug) { this.taskHandle.stdout?.pipe(process.stdout); @@ -551,6 +556,50 @@ export async function checkIfReactNativeBundles( return builtSuccessfully; } +/** + * Check if the React Native project creates a release build locally for the specified platform. + * Returns a boolean indicating if the process exits with status code 0. + * @param projectDir The root directory of the React Native project. + * @param platform The platform to build for ('ios' or 'android'). + * @param debug runs the command in debug mode if true + */ +export async function checkIfReactNativeReleaseBuilds( + projectDir: string, + platform: 'ios' | 'android', + debug = false, +): Promise { + let command: string; + let args: string[]; + let cwd: string; + let env: NodeJS.ProcessEnv; + + if (platform === 'android') { + command = './gradlew'; + args = ['assembleRelease']; + cwd = path.join(projectDir, 'android'); + env = { SENTRY_DISABLE_AUTO_UPLOAD: 'true' }; + } else { + // ios + command = 'TODO'; + args = ['TODO']; + cwd = path.join(projectDir, 'ios'); + env = {}; + } + + const testEnv = new WizardTestEnv(command, args, { + cwd: cwd, + debug: debug, + env: env, + }); + + const builtSuccessfully = await testEnv.waitForStatusCode(0, { + timeout: 1_200_000, + }); + + testEnv.kill(); + return builtSuccessfully; +} + /** * Check if the Expo project exports successfully for the specified platform. * Returns a boolean indicating if the process exits with status code 0.