Skip to content

Commit

Permalink
Test for accidental extraneous dependencies (#1825)
Browse files Browse the repository at this point in the history
* Added test to check for accidental dependencies

* Refactored test into a function

* Removed non capturing group from grep

* Update e2e-installs.sh
  • Loading branch information
lpalmes authored and Timer committed Mar 23, 2017
1 parent 47a8148 commit 1e1a3cb
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions tasks/e2e-installs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,26 @@ function exists {
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 {
node "$temp_cli_path"/node_modules/create-react-app/index.js $*
}
Expand Down Expand Up @@ -95,6 +115,7 @@ cd test-app-version-number
# Check corresponding scripts version is installed.
exists node_modules/react-scripts
grep '"version": "0.4.0"' node_modules/react-scripts/package.json
checkDependencies

# ******************************************************************************
# Test --scripts-version with a tarball url
Expand All @@ -107,6 +128,7 @@ cd test-app-tarball-url
# Check corresponding scripts version is installed.
exists node_modules/react-scripts
grep '"version": "0.4.0"' node_modules/react-scripts/package.json
checkDependencies

# ******************************************************************************
# Test --scripts-version with a custom fork of react-scripts
Expand Down Expand Up @@ -161,7 +183,7 @@ exists node_modules/@enoah_netzach/react-scripts
# Test nested folder path as the project name
# ******************************************************************************

#Testing a path that exists
# Testing a path that exists
cd "$temp_app_path"
mkdir test-app-nested-paths-t1
cd test-app-nested-paths-t1
Expand All @@ -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
npm start -- --smoke-test

#Testing a path that does not exist
# Testing a path that does not exist
cd "$temp_app_path"
create_react_app test-app-nested-paths-t2/aa/bb/cc/dd
cd test-app-nested-paths-t2/aa/bb/cc/dd
npm start -- --smoke-test

#Testing a path that is half exists
# Testing a path that is half exists
cd "$temp_app_path"
mkdir -p test-app-nested-paths-t3/aa
create_react_app test-app-nested-paths-t3/aa/bb/cc/dd
Expand Down

0 comments on commit 1e1a3cb

Please sign in to comment.