From d680580d14517fc600825541cac09b38d302b65c Mon Sep 17 00:00:00 2001 From: Alex Hunt Date: Thu, 15 Feb 2024 02:42:23 -0800 Subject: [PATCH] Fix test-e2e-local when building artifacts locally Summary: Restores behaviour of `yarn test-e2e-local` when we are not using `--circleciToken`. The `npm pack` logic (necessary for the subsequent `updateTemplatePackage` call before initing `RNTestProject`) was deleted in https://github.com/facebook/react-native/pull/41172 / D50651448. https://github.com/facebook/react-native/commit/4eed12b7df5d9731e556b77d701c87dcf91d3a1f#diff-56f57bf0eac99b0fda1b2938aceb8d9b663db82c07cb405bd53a01c8689710ffL224-L240 Changelog: [Internal] Differential Revision: D53806191 --- scripts/release-testing/test-e2e-local.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/scripts/release-testing/test-e2e-local.js b/scripts/release-testing/test-e2e-local.js index fc0f3bd32538e2..5ef32696d43637 100644 --- a/scripts/release-testing/test-e2e-local.js +++ b/scripts/release-testing/test-e2e-local.js @@ -25,6 +25,7 @@ const { prepareArtifacts, setupCircleCIArtifacts, } = require('./utils/testing-utils'); +const fs = require('fs'); const path = require('path'); const {cd, exec, popd, pushd, pwd, sed} = require('shelljs'); const yargs = require('yargs'); @@ -229,6 +230,27 @@ async function testRNTestProject( reactNativePackagePath, ); + // If artifacts were built locally, we need to pack the react-native package + if (circleCIArtifacts == null) { + exec('npm pack --pack-destination ', {cwd: reactNativePackagePath}); + + // node pack does not creates a version of React Native with the right name on main. + // Let's add some defensive programming checks: + if (!fs.existsSync(localNodeTGZPath)) { + const tarfile = fs + .readdirSync(reactNativePackagePath) + .find( + name => name.startsWith('react-native-') && name.endsWith('.tgz'), + ); + if (tarfile == null) { + throw new Error("Couldn't find a zipped version of react-native"); + } + exec( + `cp ${path.join(reactNativePackagePath, tarfile)} ${localNodeTGZPath}`, + ); + } + } + updateTemplatePackage({ 'react-native': `file://${localNodeTGZPath}`, });