Commit 1e1a3cbf authored by Lorenzo Palmes's avatar Lorenzo Palmes Committed by Joe Haddad
Browse files

Test for accidental extraneous dependencies (#1825)

* Added test to check for accidental dependencies

* Refactored test into a function

* Removed non capturing group from grep

* Update e2e-installs.sh
parent 47a8148f
Showing with 25 additions and 3 deletions
+25 -3
...@@ -46,6 +46,26 @@ function exists { ...@@ -46,6 +46,26 @@ function exists {
done done
} }
# Check for accidental dependencies in package.json
function checkDependencies {
if ! awk '/"dependencies": {/{y=1;next}/},/{y=0; next}y' package.json | \
grep -v -q -E '^\s*"react(-dom|-scripts)?"'; then
echo "Dependencies are correct"
else
echo "There are extraneous dependencies in package.json"
exit 1
fi
if ! awk '/"devDependencies": {/{y=1;next}/},/{y=0; next}y' package.json | \
grep -v -q -E '^\s*"react(-dom|-scripts)?"'; then
echo "Dev Dependencies are correct"
else
echo "There are extraneous devDependencies in package.json"
exit 1
fi
}
function create_react_app { function create_react_app {
node "$temp_cli_path"/node_modules/create-react-app/index.js $* node "$temp_cli_path"/node_modules/create-react-app/index.js $*
} }
...@@ -95,6 +115,7 @@ cd test-app-version-number ...@@ -95,6 +115,7 @@ cd test-app-version-number
# Check corresponding scripts version is installed. # Check corresponding scripts version is installed.
exists node_modules/react-scripts exists node_modules/react-scripts
grep '"version": "0.4.0"' node_modules/react-scripts/package.json grep '"version": "0.4.0"' node_modules/react-scripts/package.json
checkDependencies
# ****************************************************************************** # ******************************************************************************
# Test --scripts-version with a tarball url # Test --scripts-version with a tarball url
...@@ -107,6 +128,7 @@ cd test-app-tarball-url ...@@ -107,6 +128,7 @@ cd test-app-tarball-url
# Check corresponding scripts version is installed. # Check corresponding scripts version is installed.
exists node_modules/react-scripts exists node_modules/react-scripts
grep '"version": "0.4.0"' node_modules/react-scripts/package.json grep '"version": "0.4.0"' node_modules/react-scripts/package.json
checkDependencies
# ****************************************************************************** # ******************************************************************************
# Test --scripts-version with a custom fork of react-scripts # Test --scripts-version with a custom fork of react-scripts
...@@ -161,7 +183,7 @@ exists node_modules/@enoah_netzach/react-scripts ...@@ -161,7 +183,7 @@ exists node_modules/@enoah_netzach/react-scripts
# Test nested folder path as the project name # Test nested folder path as the project name
# ****************************************************************************** # ******************************************************************************
#Testing a path that exists # Testing a path that exists
cd "$temp_app_path" cd "$temp_app_path"
mkdir test-app-nested-paths-t1 mkdir test-app-nested-paths-t1
cd test-app-nested-paths-t1 cd test-app-nested-paths-t1
...@@ -170,13 +192,13 @@ create_react_app test-app-nested-paths-t1/aa/bb/cc/dd ...@@ -170,13 +192,13 @@ create_react_app test-app-nested-paths-t1/aa/bb/cc/dd
cd test-app-nested-paths-t1/aa/bb/cc/dd cd test-app-nested-paths-t1/aa/bb/cc/dd
npm start -- --smoke-test npm start -- --smoke-test
#Testing a path that does not exist # Testing a path that does not exist
cd "$temp_app_path" cd "$temp_app_path"
create_react_app test-app-nested-paths-t2/aa/bb/cc/dd create_react_app test-app-nested-paths-t2/aa/bb/cc/dd
cd test-app-nested-paths-t2/aa/bb/cc/dd cd test-app-nested-paths-t2/aa/bb/cc/dd
npm start -- --smoke-test npm start -- --smoke-test
#Testing a path that is half exists # Testing a path that is half exists
cd "$temp_app_path" cd "$temp_app_path"
mkdir -p test-app-nested-paths-t3/aa mkdir -p test-app-nested-paths-t3/aa
create_react_app test-app-nested-paths-t3/aa/bb/cc/dd create_react_app test-app-nested-paths-t3/aa/bb/cc/dd
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment