Skip to content

Commit 61e271b

Browse files
committed
test: fix and refactor tests
1 parent 4ff36dc commit 61e271b

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"prepublishOnly": "pinst --disable",
4646
"postpublish": "pinst --enable",
4747
"pretest": "npm run build --silent && npm pack --silent",
48-
"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",
48+
"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",
4949
"posttest": "rm husky-*.tgz",
5050
"commit": "commit"
5151
},

test/init-yarn-1.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# shellcheck source=./_functions.sh
44
. "$(dirname "$0")/_functions.sh"
55

6-
title "init"
6+
title "yarn v1"
77
tempDir="/tmp/husky-yarn-1-test"
88

99
rm -rf $tempDir

test/init-yarn-2.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# shellcheck source=./_functions.sh
44
. "$(dirname "$0")/_functions.sh"
55

6-
title "init"
6+
title "yarn v2"
77
tempDir="/tmp/husky-yarn-2-test"
88

99
rm -rf $tempDir
@@ -16,11 +16,12 @@ mkdir -p $tempDir
1616

1717
# Install
1818
cp $tgz $tempDir/husky.tgz
19-
yarn set version berry
20-
cd $tempDir && yarn init -y && yarn add ./husky.tgz
19+
cd $tempDir
20+
yarn set version berry && yarn init -y && yarn add ./husky.tgz
2121

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

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

3839
# Uninstall
40+
# Prevent yarn remove from failing due to missing husky command in postinstall
41+
npm set-script postinstall ""
3942
yarn remove husky
40-
git config core.hooksPath || ok
43+
44+
# Yarn 2 doesn't run husky's uninstall script, so core.hooksPath is still set
45+
# and needs to be manually removed
46+
git config core.hooksPath && ok
File renamed without changes.

0 commit comments

Comments
 (0)