lundi 16 novembre 2020

When to use --onlyChanged or --findRelatedTests in Jest?

I am using Jest as unit testing runner for my project, and trying to write a pre commit hook to just run a minimal set of tests, so it doesn't take too long to do a commit, which arguments should I use?

From the documentation:

--findRelatedTests:

Find and run the tests that cover a space separated list of source files that were passed in as arguments. Useful for pre-commit hook integration to run the minimal amount of tests necessary. Can be used together with --coverage to include a test coverage for the source files, no duplicate --collectCoverageFrom arguments needed.

--onlyChanged

Alias: -o. Attempts to identify which tests to run based on which files have changed in the current repository. Only works if you're running tests in a git/hg repository at the moment and requires a static dependency graph (ie. no dynamic requires).

Aucun commentaire:

Enregistrer un commentaire