Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Close the runner if metro closes unexpectedly
metro.on("close", (code) => {
if (code !== 0) {
console.error(`Metro server unexpectedly closed (code = ${code})`);
process.exit(code);
}
});
if (platform === "android") {
const devices = android.adb.devices();
const activeDevices = devices.filter(({ state }) => state === "device");
if (activeDevices.length === 0) {
throw new Error("Missing an active device: Attach a device via USB or start an emulator");
} else {
// Ensure the device can access the mocha remote server
android.adb.reverseServerPort(MochaRemoteServer.DEFAULT_CONFIG.port);
}
// Ask React Native to run the android app
rn.sync("run-android", "--no-packager");
} else if (platform === "ios") {
const deviceName = "realm-js-integration-tests";
ensureSimulator(deviceName, 'com.apple.CoreSimulator.SimDeviceType.iPhone-11');
console.log("Simulator is ready ๐");
// Ask React Native to run the ios app
rn.sync("run-ios", "--no-packager", "--simulator", deviceName);
} else {
throw new Error(`Unexpected platform: '${platform}'`);
}
// Run tests with a 5 minute timeout
return timeout(new Promise((resolve) => {
console.log("Running tests ๐โโ๏ธ");