Skip to content

Commit

Permalink
Update test runner for the react-native-example.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpojer committed Jul 25, 2016
1 parent 06d94d8 commit 8ec3aa4
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions scripts/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const rimraf = require('rimraf');
const EXAMPLES_DIR = path.resolve(__dirname, '../examples');
const INTEGRATION_TESTS_DIR = path.resolve(__dirname, '../integration_tests');
const JEST_CLI_PATH = path.resolve(__dirname, '../packages/jest-cli');
const LINKED_MODULES = ['jest-react-native'];
const VERSION = require('../lerna').version;

const packages = getPackages();
Expand All @@ -51,19 +52,23 @@ function runExampleTests(exampleDirectory) {

if (fs.existsSync(directory)) {
rimraf.sync(directory);
mkdirp.sync(directory);
// Using `npm link jest-*` can create problems with module resolution,
// so instead of this we'll create a proxy module.
fs.writeFileSync(
path.resolve(directory, 'index.js'),
`module.exports = require('${pkg}');\n`,
'utf8'
);
fs.writeFileSync(
path.resolve(directory, 'package.json'),
`{"name": "${name}", "version": "${VERSION}"}\n`,
'utf8'
);
if (LINKED_MODULES.indexOf(name) !== -1) {
runCommands(`ln -s ${pkg} ./node_modules/`, exampleDirectory);
} else {
mkdirp.sync(directory);
// Using `npm link jest-*` can create problems with module resolution,
// so instead of this we'll create a proxy module.
fs.writeFileSync(
path.resolve(directory, 'index.js'),
`module.exports = require('${pkg}');\n`,
'utf8'
);
fs.writeFileSync(
path.resolve(directory, 'package.json'),
`{"name": "${name}", "version": "${VERSION}"}\n`,
'utf8'
);
}
}
});

Expand Down

0 comments on commit 8ec3aa4

Please sign in to comment.