Skip to content

Commit

Permalink
Fix tests in template project (0.58-stable) (#23128)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
vovkasm authored and grabbou committed Jan 23, 2019
1 parent 26793a0 commit 23cfa29
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions local-cli/.npmignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
__fixtures__
__tests__
!/templates/HelloWorld/__tests__
1 change: 1 addition & 0 deletions local-cli/generator/copyProjectTemplateAndReplace.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion local-cli/init/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'});
Expand Down
3 changes: 3 additions & 0 deletions local-cli/templates/HelloWorld/_babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: ["module:metro-react-native-babel-preset"]
}
3 changes: 0 additions & 3 deletions local-cli/templates/HelloWorld/_babelrc

This file was deleted.

0 comments on commit 23cfa29

Please sign in to comment.