Skip to content

Conversation

@TrevorBurnham
Copy link

What:

When trying to commit changes, I noticed that the precommit hook failed with this error:

No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0

The root cause appears to be a known bug in Jest's --findRelatedTests feature: jestjs/jest#11527 That flag is incompatible with the roots configuration option, which kcd-scripts uses.

The fix here is to use a custom lint-staged.config.js to replace the one from kcd-scripts.

Fixes #696

Why:

With the current pre-commit hook, contributors may have to use --no-verify to 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.js is equivalent to the one from kcd-scripts, but without the --findRelatedTests flag. 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 watchPlugins config 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:

  • Documentation - N/A
  • Tests
  • Updated Type Definitions - N/A
  • Ready to be merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error when running pre-commit hook in this repo

1 participant