Skip to content

Commit

Permalink
fix(e2e): sync with React Native 0.74 (#2376)
Browse files Browse the repository at this point in the history
* fix(e2e): sync with React Native 0.74

* ci: bump gradle

* fix: do not hardcode gradle version

* ci(win): try setting `shell: true`
  • Loading branch information
szymonrybczak committed May 8, 2024
1 parent 73f880c commit 87881ef
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 53 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ jobs:
distribution: 'zulu'
java-version: 17

- uses: gradle/gradle-build-action@v2
with:
gradle-version: 8.0.1
- uses: gradle/actions/setup-gradle@v3

- uses: ruby/setup-ruby@v1
if: runner.os == 'macOS'
Expand Down
8 changes: 7 additions & 1 deletion __e2e__/__snapshots__/config.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`shows up current config without unnecessary output 1`] = `
{
"root": "<<REPLACED_ROOT>>/TestProject",
"reactNativePath": "<<REPLACED_ROOT>>/TestProject/node_modules/react-native",
"reactNativeVersion": "0.73",
"reactNativeVersion": "0.74",
"dependencies": {},
"commands": [
{
Expand Down Expand Up @@ -72,6 +72,12 @@ exports[`shows up current config without unnecessary output 1`] = `
"options": [
"<<REPLACED>>"
]
},
{
"name": "codegen",
"options": [
"<<REPLACED>>"
]
}
],
"healthChecks": [],
Expand Down
13 changes: 1 addition & 12 deletions __e2e__/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import {
writeFiles,
spawnScript,
replaceProjectRootInOutput,
getAllPackages,
addRNCPrefix,
} from '../jest/helpers';

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

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

// Register all packages to be linked
for (const pkg of packages) {
spawnScript('yarn', ['link'], {
cwd: path.join(__dirname, `../packages/${pkg}`),
});
}

// Clean up folder and re-create a new project
cleanup(DIR);
writeFiles(DIR, {});
Expand All @@ -55,7 +44,7 @@ beforeAll(() => {
runCLI(DIR, ['init', 'TestProject', '--install-pods']);

// Link CLI to the project
spawnScript('yarn', ['link', ...addRNCPrefix(packages)], {
spawnScript('yarn', ['link', __dirname, '--all'], {
cwd: path.join(DIR, 'TestProject'),
});
});
Expand Down
11 changes: 2 additions & 9 deletions __e2e__/init.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import fs from 'fs';
import path from 'path';
import {runCLI, getTempDirectory, cleanup, writeFiles} from '../jest/helpers';
import {execSync} from 'child_process';
import semver from 'semver';
import slash from 'slash';

const yarnVersion = semver.parse(execSync('yarn --version').toString().trim())!;

// .yarnrc -> .yarnrc.yml >= 2.0.0: yarnpkg/berry/issues/239
const yarnConfigFile = yarnVersion.major > 1 ? '.yarnrc.yml' : '.yarnrc';

const DIR = getTempDirectory('command-init');
const PROJECT_NAME = 'TestInit';

Expand All @@ -30,7 +23,7 @@ function createCustomTemplateFiles() {
const customTemplateCopiedFiles = [
'.git',
'.yarn',
yarnConfigFile,
'.yarnrc.yml', // .yarnrc.yml for Yarn versions >= 2.0.0
'dir',
'file',
'node_modules',
Expand Down Expand Up @@ -185,7 +178,7 @@ test('init uses npm as the package manager with --npm', () => {
// Remove yarn specific files and node_modules
const filteredFiles = customTemplateCopiedFiles.filter(
(file) =>
!['yarn.lock', 'node_modules', yarnConfigFile, '.yarn'].includes(file),
!['yarn.lock', 'node_modules', '.yarnrc.yml', '.yarn'].includes(file),
);

// Add package-lock.json
Expand Down
38 changes: 11 additions & 27 deletions __e2e__/root.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,33 @@ import {
getTempDirectory,
cleanup,
writeFiles,
addRNCPrefix,
getAllPackages,
} from '../jest/helpers';

const cwd = getTempDirectory('test_different_roots');
const DIR = getTempDirectory('test_different_roots');

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

// Register all packages to be linked
for (const pkg of packages) {
spawnScript('yarn', ['link'], {
cwd: path.join(__dirname, `../packages/${pkg}`),
});
}

// Clean up folder and re-create a new project
cleanup(cwd);
writeFiles(cwd, {});
cleanup(DIR);
writeFiles(DIR, {});

// Initialise React Native project
runCLI(cwd, ['init', 'TestProject']);
runCLI(DIR, ['init', 'TestProject', '--install-pods']);

// Link CLI to the project

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

afterAll(() => {
cleanup(cwd);
cleanup(DIR);
});

test('works when Gradle is run outside of the project hierarchy', async () => {
/**
* Location of Android project
*/
const androidProjectRoot = path.join(cwd, 'TestProject/android');
const androidProjectRoot = path.join(DIR, 'TestProject/android');

/*
* Grab absolute path to Gradle wrapper. The fact that we are using
Expand All @@ -54,13 +42,9 @@ test('works when Gradle is run outside of the project hierarchy', async () => {
const gradleWrapper = path.join(androidProjectRoot, 'gradlew');

// Make sure that we use `-bin` distribution of Gradle
await spawnScript(
gradleWrapper,
['wrapper', '--gradle-version=8.0.1', '--distribution-type', 'bin'],
{
cwd: androidProjectRoot,
},
);
await spawnScript(gradleWrapper, ['wrapper', '--distribution-type', 'bin'], {
cwd: androidProjectRoot,
});

// Execute `gradle` with `-p` flag and `cwd` outside of project hierarchy
const {stdout} = spawnScript(gradleWrapper, ['-p', androidProjectRoot], {
Expand Down
2 changes: 1 addition & 1 deletion scripts/buildTs.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ console.log(chalk.inverse('Building TypeScript definition files'));
process.stdout.write(adjustToTerminalWidth('Building\n'));

try {
execa.sync('node', args, {stdio: 'inherit'});
execa.sync('node', args, {stdio: 'inherit', shell: true});
process.stdout.write(`${OK}\n`);
} catch (e) {
process.stdout.write('\n');
Expand Down

0 comments on commit 87881ef

Please sign in to comment.