Skip to content
6 changes: 6 additions & 0 deletions e2e-tests/tests/react-native.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
cleanupGit,
checkFileContents,
checkIfReactNativeBundles,
checkIfReactNativeReleaseBuilds,
revertLocalChanges,
startWizardInstance
} from '../utils';
Expand Down Expand Up @@ -184,4 +185,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);
});
});
51 changes: 50 additions & 1 deletion e2e-tests/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<boolean> {
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iOS will be handled separately since it needs to run only on MacOS.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Followed up in #995

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.
Expand Down
Loading