Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -3,6 +3,7 @@ import {
TEST_ARGS,
checkFileContents,
checkIfReactNativeBundles,
checkIfReactNativeReleaseBuilds,
createIsolatedTestEnv,
getWizardCommand,
} from '../utils';
Expand Down Expand Up @@ -176,4 +177,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 @@ -126,9 +126,14 @@
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 @@ -519,6 +524,50 @@
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, {

Check failure on line 557 in e2e-tests/utils/index.ts

View workflow job for this annotation

GitHub Actions / Build

Cannot find name 'WizardTestEnv'.
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