Skip to content

Commit

Permalink
fix(cli): make tests independent of global git config (conventional-c…
Browse files Browse the repository at this point in the history
…hangelog#3190)

- Don't apply global changes
- Set $HOME to ensure default global settings aren't picked up
  • Loading branch information
jscheid committed May 23, 2022
1 parent 33be5ab commit 093c7ea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions @commitlint/cli/src/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ test("it doesn't use parserOpts.commentChar when using edit mode", async () => {

test('it uses core.commentChar git config when using edit mode', async () => {
const cwd = await gitBootstrap('fixtures/comment-char');
await execa('git', ['config', 'core.commentChar', '$'], {cwd});
await execa('git', ['config', '--local', 'core.commentChar', '$'], {cwd});
await fs.writeFile(
path.join(cwd, '.git', 'COMMIT_EDITMSG'),
'header: foo\n\n$body\n'
Expand All @@ -365,7 +365,6 @@ test('it uses core.commentChar git config when using edit mode', async () => {

test('it falls back to # for core.commentChar when using edit mode', async () => {
const cwd = await gitBootstrap('fixtures/comment-char');
await execa('git', ['config', '--unset', 'core.commentChar'], {cwd});
await fs.writeFile(
path.join(cwd, '.git', 'COMMIT_EDITMSG'),
'header: foo\n\n#body\n'
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"publish": "lerna publish --conventional-commits",
"reinstall": "yarn clean && yarn install",
"start": "yarn watch",
"test": "jest",
"test-ci": "jest --runInBand",
"test": "HOME=$PWD jest",
"test-ci": "HOME=$PWD jest --runInBand",
"postinstall": "yarn husky install"
},
"commitlint": {
Expand Down Expand Up @@ -106,4 +106,4 @@
"resolutions": {
"**/lodash": "^4.17.19"
}
}
}

0 comments on commit 093c7ea

Please sign in to comment.