Reputation: 4681
Hi i installed husky
& lint-stage
so as to have pre-commit hooks for lint
& tests
, for the staged files.
The pre-commit hook works, when i go to git commit -m 'something'
, and the commands are triggered.
What i have so far in terms of files is:
.husky/pre-commit
:
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx lint-staged
.package.json
:
"lint-staged": {
"*.{ts,tsx}": "eslint --cache --fix",
"*": "react-scripts test --env=jest-environment-jsdom-fourteen"
}
When i git commit ..
, (2 files, 1 *.test.ts * and 1 *.ts), it starts the linter
& the test
, but the test never finishes unless i break it(ctrl+c).
Only when i break it, i get the errors on the screen:
Also what i notice is that the lint-staged:
object, it is changed into package.json, when i git commit..
:
Initially i have it like so:
"lint-staged": {
"*.{ts,tsx}": "eslint --cache --fix",
"*.test.{ts, tsx}": "react-scripts test --env=jest-environment-jsdom-fourteen"
}
And it turns to this:
"lint-staged": {
"*.{ts,tsx}": "eslint --cache --fix",
"*": "react-scripts test --env=jest-environment-jsdom-fourteen"
}
Any help on the configuration that i miss is welcome please.
Upvotes: 0
Views: 3453
Reputation: 4681
So i fixed that issue by adding the flag --watchAll=false
in the script, we get rid of the interactions :
react-scripts test --env=jsdom --watchAll=false --bail
And by adding the --bail
flag (optional), it exits on the first failing test.
Upvotes: 3