Skip to content
Merged
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
21 changes: 12 additions & 9 deletions __e2e__/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
writeFiles,
spawnScript,
replaceProjectRootInOutput,
getAllPackages,
addRNCPrefix,
} from '../jest/helpers';

const DIR = getTempDirectory('test_root');
Expand Down Expand Up @@ -36,8 +38,10 @@ function createCorruptedSetupEnvScript() {
}

beforeAll(() => {
const packages = getAllPackages();

// Register all packages to be linked
for (const pkg of ['cli-platform-ios', 'cli-platform-android']) {
for (const pkg of packages) {
spawnScript('yarn', ['link'], {
cwd: path.join(__dirname, `../packages/${pkg}`),
});
Expand All @@ -48,18 +52,17 @@ beforeAll(() => {
writeFiles(DIR, {});

// Initialise React Native project

runCLI(DIR, ['init', 'TestProject', '--install-pods']);
runCLI(DIR, ['init', 'TestProject']);

// Link CLI to the project
const pkgs = [
'@react-native-community/cli-platform-ios',
'@react-native-community/cli-platform-android',
];

spawnScript('yarn', ['link', ...pkgs], {
spawnScript('yarn', ['link', ...addRNCPrefix(packages)], {
cwd: path.join(DIR, 'TestProject'),
});

// Install pods after linking packages because Podfile uses `use_native_modules` function that executes `config` command. In case there was introduce breaking change in `cli-config` package, it will fail since it will be using old version of the package.
spawnScript('pod', ['install'], {
cwd: path.join(DIR, 'TestProject', 'ios'),
});
});

afterAll(() => {
Expand Down
15 changes: 8 additions & 7 deletions __e2e__/root.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ import {
getTempDirectory,
cleanup,
writeFiles,
addRNCPrefix,
getAllPackages,
} from '../jest/helpers';

const cwd = getTempDirectory('test_different_roots');

beforeAll(() => {
const packages = getAllPackages();

// Register all packages to be linked
for (const pkg of ['cli-platform-ios', 'cli-platform-android']) {
for (const pkg of packages) {
spawnScript('yarn', ['link'], {
cwd: path.join(__dirname, `../packages/${pkg}`),
});
Expand All @@ -23,14 +27,11 @@ beforeAll(() => {
writeFiles(cwd, {});

// Initialise React Native project
runCLI(cwd, ['init', 'TestProject', '--install-pods']);
runCLI(cwd, ['init', 'TestProject']);
Comment on lines -26 to +30
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we don't need to install pods, since this test check only android related things.


// Link CLI to the project
const pkgs = [
'@react-native-community/cli-platform-ios',
'@react-native-community/cli-platform-android',
];

spawnScript('yarn', ['link', ...pkgs], {
spawnScript('yarn', ['link', ...addRNCPrefix(packages)], {
cwd: path.join(cwd, 'TestProject'),
});
});
Expand Down
8 changes: 8 additions & 0 deletions jest/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,11 @@ export function replaceProjectRootInOutput(output: string, testFolder: string) {
const regex = new RegExp(`(:\\s").*(${slash(testFolder)})`, 'g');
return slash(output).replace(regex, '$1<<REPLACED_ROOT>>');
}

export function getAllPackages() {
return fs.readdirSync(path.resolve(__dirname, '../packages'));
}

export function addRNCPrefix(packages: string[]) {
return packages.map((p) => `@react-native-community/${p}`);
}
1 change: 1 addition & 0 deletions packages/cli-platform-ios/src/tools/installPods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ async function runPodInstall(loader: Ora, options?: RunPodInstallOptions) {
},
});
} catch (error) {
logger.debug(error as string);
// "pod" command outputs errors to stdout (at least some of them)
const stderr = (error as any).stderr || (error as any).stdout;

Expand Down