Skip to content
This repository has been archived by the owner on Dec 15, 2020. It is now read-only.

Commit

Permalink
Cleaned up e2e tests out of unused imports etc.
Browse files Browse the repository at this point in the history
Summary:
## Motivation (required)

I've noticed that there were some unused import statements in e2e tests and some minor code quality issues (like unintended `if` statement in `jest/prepareE2E.js`), this PR addresses that.

## Test Plan (required)

`npm run tests` passes just fine
Closes #126

Reviewed By: mikearmstrong001

Differential Revision: D4957532

Pulled By: mikearmstrong001

fbshipit-source-id: 84bb031
  • Loading branch information
Tomasz Lakomy authored and facebook-github-bot committed Apr 28, 2017
1 parent 4622d07 commit 3082d7e
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 88 deletions.
2 changes: 0 additions & 2 deletions EndToEnd/runner/MockWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/

import fs from 'fs';
import path from 'path';
import vm from 'vm';
import {_getObjectFromURL} from './MockURL';

Expand Down
3 changes: 1 addition & 2 deletions EndToEnd/testapp/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ function init(bundle, parent, options) {
const vr = new VRInstance(bundle, 'End2End', parent, {
...options,
});
vr.render = function() {
};
vr.render = function() {};
// Begin the animation loop
vr.start();
window.vr = vr;
Expand Down
11 changes: 2 additions & 9 deletions EndToEnd/testapp/e2e.vr.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
'use strict';

import React from 'react';
import {
AppRegistry,
asset,
NativeModules,
Pano,
Text,
View,
} from 'react-vr';
import {AppRegistry, NativeModules, Text, View} from 'react-vr';

window.NativeModules = NativeModules;

Expand All @@ -32,6 +25,6 @@ class End2End extends React.Component {
</View>
);
}
};
}

AppRegistry.registerComponent('End2End', () => End2End);
148 changes: 73 additions & 75 deletions jest/prepareE2E.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,84 +8,82 @@ console.log('Running full test suite.');
console.log('If you want to skip the end-to-end tests, run `npm run test-unit`\n');

if (!process.env.SKIPBUILD) {
console.log('Building React VR apps for end-to-end testing.');
console.log('If you don\'t want to do this for every test run, set SKIPBUILD=1.');
console.log(' SKIPBUILD=1 npm test');

console.log('Building React VR apps for end-to-end testing.');
console.log('If you don\'t want to do this for every test run, set SKIPBUILD=1.');
console.log(' SKIPBUILD=1 npm test');
function buildScript(root, input, output) {
const cliLocation = require.resolve('react-native/local-cli/cli.js');
const configLocation = path.resolve(root, 'rn-cli.config.js');
return new Promise(function(resolve, reject) {
const npm = child_process.spawn(
(/^win/.test(process.platform) ? 'node.exe' : 'node'),
[
cliLocation,
'bundle',
'--entry-file',
input,
'--platform',
'vr',
'--bundle-output',
output,
'--dev',
'false',
'--config',
configLocation,
'--reset-cache'
],
{stdio: 'inherit', cwd: root}
);
npm.on('close', function(code) {
if (code !== 0) {
reject(code);
}
resolve();
});
});
}

function buildScript(root, input, output) {
const cliLocation = require.resolve('react-native/local-cli/cli.js');
const configLocation = path.resolve(root, 'rn-cli.config.js');
return new Promise(function(resolve, reject) {
const npm = child_process.spawn(
(/^win/.test(process.platform) ? 'node.exe' : 'node'),
[
cliLocation,
'bundle',
'--entry-file',
input,
'--platform',
'vr',
'--bundle-output',
output,
'--dev',
'false',
'--config',
configLocation,
'--reset-cache'
],
{stdio: 'inherit', cwd: root}
);
npm.on('close', function(code) {
if (code !== 0) {
reject(code);
const rootDir = path.resolve(__dirname, '..', 'EndToEnd', 'testapp');

new Promise(function(resolve, reject) {
const buildDir = path.join(rootDir, 'build');
try {
const stat = fs.statSync(buildDir);
if (stat.isDirectory()) {
return resolve();
}
} catch (e) {}
fs.mkdir(path.join(rootDir, 'build'), function(err) {
if (err) {
console.log('Failed to create `testapp/build` directory');
return reject(1);
}
resolve();
});
}).then(function() {
return Promise.all([
buildScript(
rootDir,
path.resolve(rootDir, 'e2e.vr.js'),
path.resolve(rootDir, 'build', 'e2e.bundle.js')
),
buildScript(
rootDir,
path.resolve(rootDir, 'client.js'),
path.resolve(rootDir, 'build', 'client.bundle.js')
),
]);
}).then(function() {
console.log(
'Production versions were successfully built.' +
'They can be found at ' + path.resolve(rootDir, 'build')
);
}).catch(function(err) {
console.log(
'An error occurred during the bundling process. Exited with code ' + err +
'.\nLook at the packager output above to see what went wrong.'
);
process.exit(1);
});
}

const rootDir = path.resolve(__dirname, '..', 'EndToEnd', 'testapp');

new Promise(function(resolve, reject) {
const buildDir = path.join(rootDir, 'build');
try {
const stat = fs.statSync(buildDir);
if (stat.isDirectory()) {
return resolve();
}
} catch (e) {}
fs.mkdir(path.join(rootDir, 'build'), function(err) {
if (err) {
console.log('Failed to create `testapp/build` directory');
return reject(1);
}
resolve();
});
}).then(function() {
return Promise.all([
buildScript(
rootDir,
path.resolve(rootDir, 'e2e.vr.js'),
path.resolve(rootDir, 'build', 'e2e.bundle.js')
),
buildScript(
rootDir,
path.resolve(rootDir, 'client.js'),
path.resolve(rootDir, 'build', 'client.bundle.js')
),
]);
}).then(function() {
console.log(
'Production versions were successfully built.' +
'They can be found at ' + path.resolve(rootDir, 'build')
);
}).catch(function(err) {
console.log(
'An error occurred during the bundling process. Exited with code ' + err +
'.\nLook at the packager output above to see what went wrong.'
);
process.exit(1);
});

}
}

0 comments on commit 3082d7e

Please sign in to comment.