Skip to content

Commit

Permalink
Enable js e2e tests (#23571)
Browse files Browse the repository at this point in the history
Summary:
Part of #23561. Small refactor to use 1 marker for the different tests, as it doesn't matter where it is- so long as we can detect it.

[General] [Fixed] - turn on JS e2e tests
Pull Request resolved: #23571

Differential Revision: D14172069

Pulled By: hramos

fbshipit-source-id: cdde369a09d3528d05fec01d015613b3397714e6
  • Loading branch information
ericlewis authored and facebook-github-bot committed Feb 21, 2019
1 parent d9489c4 commit 9ca7565
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 40 deletions.
13 changes: 4 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,9 @@ aliases:
name: iOS End-to-End Test Suite
command: node ./scripts/run-ci-e2e-tests.js --ios --retries 3;

- &display-broken-tests-warning
name: Running broken tests (Ignore any failures past this point)
command: |
echo 'The following steps are known to be failing on master.'
echo 'They will no-op for most users.'
echo 'PRs that bring these back to green are appreciated.'
- &run-js-e2e-tests
name: JavaScript End-to-End Test Suite
command: node ./scripts/run-ci-e2e-tests.js --js --retries 3;

# DISABLED TESTS
- &run-podspec-tests
Expand All @@ -262,9 +259,6 @@ aliases:
- &run-android-e2e-tests
name: Android End-to-End Test Suite
command: node ./scripts/run-ci-e2e-tests.js --android --retries 3;
- &run-js-e2e-tests
name: JavaScript End-to-End Test Suite
command: node ./scripts/run-ci-e2e-tests.js --js --retries 3;

defaults: &defaults
working_directory: ~/react-native
Expand Down Expand Up @@ -338,6 +332,7 @@ jobs:
at: ~/react-native

- run: *run-js-tests
- run: *run-js-e2e-tests

- store_test_results:
path: ~/react-native/reports/junit
Expand Down
46 changes: 15 additions & 31 deletions scripts/run-ci-e2e-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,26 @@ const TEMP = exec('mktemp -d /tmp/react-native-XXXXXXXX').stdout.trim();
// To make sure we actually installed the local version
// of react-native, we will create a temp file inside the template
// and check that it exists after `react-native init
const MARKER_IOS = exec(
`mktemp ${ROOT}/template/ios/HelloWorld/XXXXXXXX`,
).stdout.trim();
const MARKER_ANDROID = exec(
`mktemp ${ROOT}/template/android/XXXXXXXX`,
).stdout.trim();
const MARKER = exec(`mktemp ${ROOT}/template/XXXXXXXX`).stdout.trim();
const numberOfRetries = argv.retries || 1;
let SERVER_PID;
let APPIUM_PID;
let exitCode;

// Make sure we installed local version of react-native
function checkMarker() {
if (!test('-e', path.basename(MARKER))) {
echo('Marker was not found, react native init command failed?');
exitCode = 1;
throw Error(exitCode);
}
}

try {
// install CLI
const CLI_PACKAGE = 'react-native-cli';
if (!argv['skip-cli-install']) {
if (exec(`sudo yarn global add ${CLI_PACKAGE}`).code) {
if (exec(`yarn global add ${CLI_PACKAGE}`).code) {
echo('Could not install react-native-cli globally.');
echo('Run with --skip-cli-install to skip this step');
exitCode = 1;
Expand Down Expand Up @@ -97,6 +101,7 @@ try {

if (argv.android) {
echo('Running an Android end-to-end test');
checkMarker();
echo('Installing end-to-end framework');
if (
tryExecNTimes(
Expand All @@ -117,12 +122,6 @@ try {
cd('android');
echo('Downloading Maven deps');
exec('./gradlew :app:copyDownloadableDepsToLibs');
// Make sure we installed local version of react-native
if (!test('-e', path.basename(MARKER_ANDROID))) {
echo('Android marker was not found, react native init command failed?');
exitCode = 1;
throw Error(exitCode);
}
cd('..');
exec(
'keytool -genkey -v -keystore android/keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"',
Expand Down Expand Up @@ -162,15 +161,10 @@ try {
}

if (argv.ios || argv.tvos) {
checkMarker();
var iosTestType = argv.tvos ? 'tvOS' : 'iOS';
echo('Running the ' + iosTestType + ' app');
cd('ios');
// Make sure we installed local version of react-native
if (!test('-e', path.join('EndToEndTest', path.basename(MARKER_IOS)))) {
echo('iOS marker was not found, `react-native init` command failed?');
exitCode = 1;
throw Error(exitCode);
}
// shelljs exec('', {async: true}) does not emit stdout events, so we rely on good old spawn
const packagerEnv = Object.create(process.env);
packagerEnv.REACT_NATIVE_MAX_WORKERS = 1;
Expand Down Expand Up @@ -232,6 +226,7 @@ try {
}

if (argv.js) {
checkMarker();
// Check the packager produces a bundle (doesn't throw an error)
if (
exec(
Expand All @@ -251,22 +246,11 @@ try {
exitCode = 1;
throw Error(exitCode);
}
if (exec(`${ROOT}/node_modules/.bin/flow check`).code) {
echo('Flow check does not pass');
exitCode = 1;
throw Error(exitCode);
}
if (exec('yarn test').code) {
echo('Jest test failure');
exitCode = 1;
throw Error(exitCode);
}
}
exitCode = 0;
} finally {
cd(ROOT);
rm(MARKER_IOS);
rm(MARKER_ANDROID);
rm(MARKER);

if (SERVER_PID) {
echo(`Killing packager ${SERVER_PID}`);
Expand Down

0 comments on commit 9ca7565

Please sign in to comment.