Skip to content

Commit

Permalink
test: fix and refactor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
typicode committed Mar 2, 2021
1 parent 4ff36dc commit 61e271b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -45,7 +45,7 @@
"prepublishOnly": "pinst --disable",
"postpublish": "pinst --enable",
"pretest": "npm run build --silent && npm pack --silent",
"test": "sh ./test/init-npm.sh && sh ./test/init-yarn-2.sh && sh ./test/default.sh && sh ./test/sub-dir.sh && sh ./test/config-dir.sh && sh ./test/not-git-dir.sh",
"test": "sh ./test/init.sh && sh ./test/init-yarn-2.sh && sh ./test/default.sh && sh ./test/sub-dir.sh && sh ./test/config-dir.sh && sh ./test/not-git-dir.sh",
"posttest": "rm husky-*.tgz",
"commit": "commit"
},
Expand Down
2 changes: 1 addition & 1 deletion test/init-yarn-1.sh
Expand Up @@ -3,7 +3,7 @@
# shellcheck source=./_functions.sh
. "$(dirname "$0")/_functions.sh"

title "init"
title "yarn v1"
tempDir="/tmp/husky-yarn-1-test"

rm -rf $tempDir
Expand Down
14 changes: 10 additions & 4 deletions test/init-yarn-2.sh
Expand Up @@ -3,7 +3,7 @@
# shellcheck source=./_functions.sh
. "$(dirname "$0")/_functions.sh"

title "init"
title "yarn v2"
tempDir="/tmp/husky-yarn-2-test"

rm -rf $tempDir
Expand All @@ -16,11 +16,12 @@ mkdir -p $tempDir

# Install
cp $tgz $tempDir/husky.tgz
yarn set version berry
cd $tempDir && yarn init -y && yarn add ./husky.tgz
cd $tempDir
yarn set version berry && yarn init -y && yarn add ./husky.tgz

init_git
yarn husky init
yarn # will install pinst
npm set-script test "echo \"msg from pre-commit hook\" && exit 1"

# Test package.json scripts
Expand All @@ -36,5 +37,10 @@ git add package.json
git commit -m "should fail" || ok

# Uninstall
# Prevent yarn remove from failing due to missing husky command in postinstall
npm set-script postinstall ""
yarn remove husky
git config core.hooksPath || ok

# Yarn 2 doesn't run husky's uninstall script, so core.hooksPath is still set
# and needs to be manually removed
git config core.hooksPath && ok
File renamed without changes.

0 comments on commit 61e271b

Please sign in to comment.