Fix tests in template project (0.58-stable) (#23128)

* Restore __tests__ folder in HelloWorld template

PR #18019 Removed __tests__ and __fixtures__ folders from npm package.
But it also effectively removed __tests__ folder from initial project
template. This commit restores __tests__ in template application.

It applicable only to 0.58-stable branch because in master, templates
was moved to another location. I think we should recheck what is ignored
in master after this landed.

* Use babel.config.js in template HelloWorld application

* Add babel-core@^7.0.0-bridge.0 to jest dependencies when react-native init new project. This should fix tests with babel7.
This commit is contained in:
Vladimir Timofeev 2019-01-23 21:00:39 +03:00 committed by Mike Grabowski
parent 26793a052a
commit 23cfa29ac7
5 changed files with 6 additions and 4 deletions

View File

@ -1,2 +1,3 @@
__fixtures__
__tests__
!/templates/HelloWorld/__tests__

View File

@ -127,6 +127,7 @@ function translateFilePath(path) {
.replace('_BUCK', 'BUCK')
.replace('_gitignore', '.gitignore')
.replace('_gitattributes', '.gitattributes')
.replace('_babel.config.js', 'babel.config.js')
.replace('_babelrc', '.babelrc')
.replace('_flowconfig', '.flowconfig')
.replace('_buckconfig', '.buckconfig')

View File

@ -90,7 +90,7 @@ function generateProject(destinationRoot, newProjectName, options) {
});
}
if (!options['skip-jest']) {
const jestDeps = `jest babel-jest metro-react-native-babel-preset react-test-renderer@${reactVersion}`;
const jestDeps = `jest babel-core@^7.0.0-bridge.0 babel-jest metro-react-native-babel-preset react-test-renderer@${reactVersion}`;
if (yarnVersion) {
console.log('Adding Jest...');
execSync(`yarn add ${jestDeps} --dev --exact`, {stdio: 'inherit'});

View File

@ -0,0 +1,3 @@
module.exports = {
presets: ["module:metro-react-native-babel-preset"]
}

View File

@ -1,3 +0,0 @@
{
"presets": ["module:metro-react-native-babel-preset"]
}