Skip to content

Commit 23cfa29

Browse files
vovkasmgrabbou
authored andcommitted
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.
1 parent 26793a0 commit 23cfa29

File tree

5 files changed

+6
-4
lines changed

5 files changed

+6
-4
lines changed

local-cli/.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
__fixtures__
22
__tests__
3+
!/templates/HelloWorld/__tests__

local-cli/generator/copyProjectTemplateAndReplace.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ function translateFilePath(path) {
127127
.replace('_BUCK', 'BUCK')
128128
.replace('_gitignore', '.gitignore')
129129
.replace('_gitattributes', '.gitattributes')
130+
.replace('_babel.config.js', 'babel.config.js')
130131
.replace('_babelrc', '.babelrc')
131132
.replace('_flowconfig', '.flowconfig')
132133
.replace('_buckconfig', '.buckconfig')

local-cli/init/init.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function generateProject(destinationRoot, newProjectName, options) {
9090
});
9191
}
9292
if (!options['skip-jest']) {
93-
const jestDeps = `jest babel-jest metro-react-native-babel-preset react-test-renderer@${reactVersion}`;
93+
const jestDeps = `jest babel-core@^7.0.0-bridge.0 babel-jest metro-react-native-babel-preset react-test-renderer@${reactVersion}`;
9494
if (yarnVersion) {
9595
console.log('Adding Jest...');
9696
execSync(`yarn add ${jestDeps} --dev --exact`, {stdio: 'inherit'});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
presets: ["module:metro-react-native-babel-preset"]
3+
}

local-cli/templates/HelloWorld/_babelrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)