Skip to content

Commit e315ec9

Browse files
hramosfacebook-github-bot
authored andcommitted
Fix iOS e2e tests: bump react-native-babel-preset to ^5 (#19625)
Summary: We opt in to version ^5 of the React Native Babel Preset, as required after the bump to Babel 7. This fixes the Objective-C end-to-end test failure in master. (Fixes #19538) See 34bd776#commitcomment-29024085 for prior discussion. There have already been several changes made to the repo during the transition to Babel 7. This PR brings all tests back to green and allows us to move forward with the 0.56 branch cut. We also bump our tests to use Xcode 9.4.0 and iOS 11.4, the latest stable versions of both. Once the 0.56 branch makes it to stable, we can change `react-native-babel-preset@latest` on npm to point to `[email protected]` (or newer), and undo the change made to `init.js` we made as part of this diff. Wait for Circle CI to run: https://circleci.com/workflow-run/e39a66d7-bf8a-4b31-a22f-eef30a2c53bc [GENERAL] [BREAKING] [Babel] - Bump React Native Babel Preset version used by RN CLI to Babel v7 compliant release Closes #19625 Reviewed By: TheSavior Differential Revision: D8343861 Pulled By: hramos fbshipit-source-id: 42644d5b0bfb40a8bc592ae3461c5008deef8232
1 parent a51e8b1 commit e315ec9

File tree

8 files changed

+84
-44
lines changed

8 files changed

+84
-44
lines changed

.circleci/config.yml

+33-17
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ aliases:
198198
# eslint sometimes runs into trouble generating the reports
199199
- &run-lint-checks
200200
name: Lint code
201-
command: scripts/circleci/exec_swallow_error.sh yarn lint --format junit -o ~/react-native/reports/junit/js-lint-results.xml
201+
command: scripts/circleci/exec_swallow_error.sh yarn lint --format junit -o ~/react-native/reports/junit/eslint/results.xml
202202
when: always
203203

204204
- &run-flow-checks
@@ -274,6 +274,14 @@ aliases:
274274
mkdir -p ~/react-native/reports/junit/
275275
mkdir -p ~/react-native/reports/outputs/
276276
277+
- &boot-simulator-iphone
278+
name: Boot iPhone Simulator
279+
command: xcrun simctl boot "iPhone 5s" || true
280+
281+
- &boot-simulator-appletv
282+
name: Boot Apple TV Simulator
283+
command: xcrun simctl boot "Apple TV" || true
284+
277285
- &run-objc-ios-tests
278286
name: iOS Test Suite
279287
command: ./scripts/objc-test-ios.sh test
@@ -282,9 +290,13 @@ aliases:
282290
name: tvOS Test Suite
283291
command: ./scripts/objc-test-tvos.sh test
284292

293+
- &run-e2e-tests
294+
name: End-to-End Test Suite
295+
command: node ./scripts/run-ci-e2e-tests.js --ios --tvos --js --retries 3;
296+
285297
- &run-objc-ios-e2e-tests
286298
name: iOS End-to-End Test Suite
287-
command: node ./scripts/run-ci-e2e-tests.js --ios --js --retries 3;
299+
command: node ./scripts/run-ci-e2e-tests.js --ios --retries 3;
288300

289301
- &run-objc-tvos-e2e-tests
290302
name: tvOS End-to-End Test Suite
@@ -374,8 +386,7 @@ jobs:
374386
- attach_workspace:
375387
at: ~/react-native
376388

377-
- run: xcrun instruments -w "iPhone 5s (11.4)" || true
378-
# See https://github.com/Homebrew/homebrew-core/issues/26358.
389+
- run: *boot-simulator-iphone
379390
- run: brew install watchman
380391
- run: *run-objc-ios-tests
381392

@@ -389,22 +400,35 @@ jobs:
389400
- attach_workspace:
390401
at: ~/react-native
391402

392-
- run: xcrun instruments -w "Apple TV (11.4)" || true
393-
# See https://github.com/Homebrew/homebrew-core/issues/26358.
403+
- run: *boot-simulator-appletv
394404
- run: brew install watchman
395405
- run: *run-objc-tvos-tests
396406

397407
- store_test_results:
398408
path: ~/react-native/reports/junit
399409

400410
# Runs end to end tests
401-
test_ios_e2e:
411+
test_end_to_end:
402412
<<: *macos_defaults
403413
steps:
404414
- attach_workspace:
405415
at: ~/react-native
406416

407-
- run: xcrun instruments -w "iPhone 5s (11.4)" || true
417+
- run: *boot-simulator-iphone
418+
419+
- run:
420+
name: Configure Environment Variables
421+
command: |
422+
echo 'export PATH=/usr/local/opt/node@8/bin:$PATH' >> $BASH_ENV
423+
source $BASH_ENV
424+
425+
- run:
426+
name: Install Node 8
427+
command: |
428+
brew install node@8
429+
brew link node@8
430+
node -v
431+
408432
- run: *run-objc-ios-e2e-tests
409433

410434
- store_test_results:
@@ -623,7 +647,7 @@ workflows:
623647
- checkout_code
624648

625649
# End-to-end tests
626-
- test_ios_e2e:
650+
- test_end_to_end:
627651
filters: *filter-ignore-gh-pages
628652
requires:
629653
- checkout_code
@@ -670,11 +694,3 @@ workflows:
670694
# filters: *filter-ignore-gh-pages
671695
# requires:
672696
# - checkout_code
673-
674-
experimental:
675-
notify:
676-
webhooks:
677-
- url: https://code.facebook.com/circle/webhook/
678-
branches:
679-
only:
680-
- master

ContainerShip/scripts/run-android-ci-instrumentation-tests.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const path = require('path');
2828
const colors = {
2929
GREEN: '\x1b[32m',
3030
RED: '\x1b[31m',
31-
RESET: '\x1b[0m'
31+
RESET: '\x1b[0m',
3232
};
3333

3434
const test_opts = {
@@ -41,7 +41,7 @@ const test_opts = {
4141
TEST_TIMEOUT: parseInt(argv['test-timeout'] || 1000 * 60 * 10),
4242

4343
OFFSET: argv.offset,
44-
COUNT: argv.count
44+
COUNT: argv.count,
4545
};
4646

4747
let max_test_class_length = Number.NEGATIVE_INFINITY;
@@ -88,7 +88,7 @@ return async.mapSeries(testClasses, (clazz, callback) => {
8888

8989
return async.retry(test_opts.RETRIES, (retryCb) => {
9090
const test_process = child_process.spawn('./ContainerShip/scripts/run-instrumentation-tests-via-adb-shell.sh', [test_opts.PACKAGE, clazz], {
91-
stdio: 'inherit'
91+
stdio: 'inherit',
9292
});
9393

9494
const timeout = setTimeout(() => {
@@ -112,7 +112,7 @@ return async.mapSeries(testClasses, (clazz, callback) => {
112112
}, (err) => {
113113
return callback(null, {
114114
name: clazz,
115-
status: err ? 'failure' : 'success'
115+
status: err ? 'failure' : 'success',
116116
});
117117
});
118118
}, (err, results) => {

local-cli/init/init.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function generateProject(destinationRoot, newProjectName, options) {
9999
});
100100
}
101101
if (!options['skip-jest']) {
102-
const jestDeps = `jest babel-jest babel-preset-react-native react-test-renderer@${reactVersion}`;
102+
const jestDeps = `jest babel-jest babel-preset-react-native@^5 react-test-renderer@${reactVersion}`;
103103
if (yarnVersion) {
104104
console.log('Adding Jest...');
105105
execSync(`yarn add ${jestDeps} --dev --exact`, {stdio: 'inherit'});

scripts/.tests.env

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export AVD_NAME="testAVD"
1717
export AVD_ABI=x86
1818

1919
## IOS ##
20-
export IOS_TARGET_OS="11.3"
20+
export IOS_TARGET_OS="11.4"
2121
export IOS_DEVICE="iPhone 5s"
2222

2323
export SCHEME="RNTester"

scripts/objc-test-ios.sh

+4-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ ROOT=$(dirname "$SCRIPTS")
1313

1414
cd "$ROOT"
1515

16-
SCHEME="RNTester"
17-
SDK="iphonesimulator"
18-
DESTINATION="platform=iOS Simulator,name=iPhone 5s,OS=10.3.1"
16+
export TEST_NAME="iOS"
17+
export SCHEME="RNTester"
18+
export SDK="iphonesimulator"
19+
export DESTINATION="platform=iOS Simulator,name=iPhone 5s,OS=11.4"
1920

2021
# If there's a "test" argument, pass it to the test script.
2122
. ./scripts/objc-test.sh $1

scripts/objc-test-tvos.sh

+4-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ ROOT=$(dirname "$SCRIPTS")
1313

1414
cd "$ROOT"
1515

16-
SCHEME="RNTester-tvOS"
17-
SDK="appletvsimulator"
18-
DESTINATION="platform=tvOS Simulator,name=Apple TV 1080p,OS=10.2"
16+
export TEST_NAME="tvOS"
17+
export SCHEME="RNTester-tvOS"
18+
export SDK="appletvsimulator"
19+
export DESTINATION="platform=tvOS Simulator,name=Apple TV,OS=11.4"
1920

2021
# If there's a "test" argument, pass it to the test script.
2122
. ./scripts/objc-test.sh $1

scripts/objc-test.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ xcodebuild \
7979
-sdk $SDK \
8080
-destination "$DESTINATION" \
8181
build test \
82-
| xcpretty --report junit --output ~/react-native/reports/junit/objc-xcodebuild-results.xml
82+
| xcpretty --report junit --output "$HOME/react-native/reports/junit/$TEST_NAME/results.xml"
8383

8484
else
8585

scripts/run-ci-e2e-tests.js

+36-14
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ try {
104104
cd('EndToEndTest');
105105

106106
if (argv.android) {
107-
echo('Running an Android e2e test');
108-
echo('Installing e2e framework');
107+
echo('Running an Android end-to-end test');
108+
echo('Installing end-to-end framework');
109109
if (
110110
tryExecNTimes(
111111
() =>
@@ -155,14 +155,14 @@ try {
155155
SERVER_PID = packagerProcess.pid;
156156
// wait a bit to allow packager to startup
157157
exec('sleep 15s');
158-
echo('Executing android e2e test');
158+
echo('Executing android end-to-end test');
159159
if (
160160
tryExecNTimes(() => {
161161
exec('sleep 10s');
162162
return exec('node node_modules/.bin/_mocha android-e2e-test.js').code;
163163
}, numberOfRetries)
164164
) {
165-
echo('Failed to run Android e2e tests');
165+
echo('Failed to run Android end-to-end tests');
166166
echo('Most likely the code is broken');
167167
exitCode = 1;
168168
throw Error(exitCode);
@@ -171,7 +171,7 @@ try {
171171

172172
if (argv.ios || argv.tvos) {
173173
var iosTestType = argv.tvos ? 'tvOS' : 'iOS';
174-
echo('Running the ' + iosTestType + 'app');
174+
echo('Running the ' + iosTestType + ' app');
175175
cd('ios');
176176
// Make sure we installed local version of react-native
177177
if (!test('-e', path.join('EndToEndTest', path.basename(MARKER_IOS)))) {
@@ -193,22 +193,44 @@ try {
193193
'response=$(curl --write-out %{http_code} --silent --output /dev/null localhost:8081/index.bundle?platform=ios&dev=true)',
194194
);
195195
echo(`Starting packager server, ${SERVER_PID}`);
196-
echo('Executing ' + iosTestType + ' e2e test');
196+
echo('Executing ' + iosTestType + ' end-to-end test');
197197
if (
198198
tryExecNTimes(() => {
199199
exec('sleep 10s');
200+
let destination = 'platform=iOS Simulator,name=iPhone 5s,OS=11.4';
201+
let sdk = 'iphonesimulator';
202+
let scheme = 'EndToEndTest';
203+
200204
if (argv.tvos) {
201-
return exec(
202-
'xcodebuild -destination "platform=tvOS Simulator,name=Apple TV 1080p,OS=10.0" -scheme EndToEndTest-tvOS -sdk appletvsimulator test | xcpretty && exit ${PIPESTATUS[0]}',
203-
).code;
204-
} else {
205-
return exec(
206-
'xcodebuild -destination "platform=iOS Simulator,name=iPhone 5s,OS=10.3.1" -scheme EndToEndTest -sdk iphonesimulator test | xcpretty && exit ${PIPESTATUS[0]}',
207-
).code;
205+
destination = 'platform=tvOS Simulator,name=Apple TV,OS=11.4';
206+
sdk = 'appletvsimulator';
207+
scheme = 'EndToEndTest-tvOS';
208208
}
209+
210+
return exec(
211+
[
212+
'xcodebuild',
213+
'-destination',
214+
`"${destination}"`,
215+
'-scheme',
216+
`"${scheme}"`,
217+
'-sdk',
218+
sdk,
219+
'test',
220+
].join(' ') +
221+
' | ' +
222+
[
223+
'xcpretty',
224+
'--report',
225+
'junit',
226+
'--output',
227+
`"~/react-native/reports/junit/${iosTestType}-e2e/results.xml"`,
228+
].join(' ') +
229+
' && exit ${PIPESTATUS[0]}',
230+
).code;
209231
}, numberOfRetries)
210232
) {
211-
echo('Failed to run ' + iosTestType + ' e2e tests');
233+
echo('Failed to run ' + iosTestType + ' end-to-end tests');
212234
echo('Most likely the code is broken');
213235
exitCode = 1;
214236
throw Error(exitCode);

0 commit comments

Comments
 (0)