From d9041644347cdb51bc5c6f7ea5913588d466ce20 Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Fri, 17 Mar 2023 10:26:34 -0700 Subject: [PATCH] Make robolectric tests run in offline mode (#36510) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/36510 This sets up a small offline mirror for Robolectric tests and allows to run them both on CircleCI and on the internal CI. allow-large-files Changelog: [Internal] [Changed] - Make robolectric tests run in offline mode Reviewed By: cipolleschi Differential Revision: D44066692 fbshipit-source-id: 3974d92169ed5c8947f72c953e83a7bf6fadca54 --- packages/react-native/ReactAndroid/build.gradle | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/react-native/ReactAndroid/build.gradle b/packages/react-native/ReactAndroid/build.gradle index be0f85cb640..24d20ffbf08 100644 --- a/packages/react-native/ReactAndroid/build.gradle +++ b/packages/react-native/ReactAndroid/build.gradle @@ -647,6 +647,17 @@ android { includeBuildTypeValues('debug', 'release') } } + + testOptions { + unitTests.all { + // Robolectric tests are downloading JARs at runtime. This allows to specify + // a local file mirror with REACT_NATIVE_ROBOLECTRIC_MIRROR to go in offline more. + if (System.getenv("REACT_NATIVE_ROBOLECTRIC_MIRROR") != null) { + systemProperty 'robolectric.offline', 'true' + systemProperty 'robolectric.dependency.dir', System.getenv("REACT_NATIVE_ROBOLECTRIC_MIRROR") + } + } + } } dependencies {