chore: run all tests in pre-commit hook to avoid 'No tests found' error #709
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What:
When trying to commit changes, I noticed that the precommit hook failed with this error:
The root cause appears to be a known bug in Jest's
--findRelatedTestsfeature: jestjs/jest#11527 That flag is incompatible with therootsconfiguration option, which kcd-scripts uses.The fix here is to use a custom
lint-staged.config.jsto replace the one from kcd-scripts.Fixes #696
Why:
With the current pre-commit hook, contributors may have to use
--no-verifyto commit their changes. That adds a significant amount of friction to contributions, and also means that those contributions won't benefit from being linted and formatted via lint-staged.How:
The custom
lint-staged.config.jsis equivalent to the one from kcd-scripts, but without the--findRelatedTestsflag. Since all of this repo's tests take only a few seconds to run, I don't think this is overly burdensome.I've also removed the
watchPluginsconfig options from the Jest config to address "Unknown option" validation warnings emitted when running the tests. See #696 for example output.Lastly, I've added
.jest-cache/to.gitignore, as I noticed that files were being created there.Checklist: