I have a project created using Create-React-App. I am looking to add in a precommit
hook to run our linter and tests with the pre-commit
package.
"pre-commit": [
"precommit-msg",
"lint",
"test"
],
However, since the test script runs by default in watch mode, this prevents the commit from ever actually happening. How can add the tests not in watch move in the pre-commit?
You can use the --watchAll=false parameter. So for example you can create another script like this:
"scripts": {
"test:nowatch": "react-scripts test --watchAll=false",
}
And then run
"pre-commit": [
"precommit-msg",
"lint",
"test:nowatch"
],