Skip to content

Commit

Permalink
Fix test-e2e-local when building artifacts locally
Browse files Browse the repository at this point in the history
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 #41172 / D50651448.

4eed12b#diff-56f57bf0eac99b0fda1b2938aceb8d9b663db82c07cb405bd53a01c8689710ffL224-L240

Changelog: [Internal]

Differential Revision: D53806191
  • Loading branch information
huntie authored and facebook-github-bot committed Feb 15, 2024
1 parent 59d46e8 commit d680580
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions scripts/release-testing/test-e2e-local.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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}`,
});
Expand Down

0 comments on commit d680580

Please sign in to comment.