Skip to content

Coverage

The Coverage Pipe allows you to dynamically filter tests based on actual code changes and a coverage report. It uses Git diff and a coverage file to detect which tests are impacted by modified files, so you only run what’s necessary.

This is useful for:

  • Running only tests related to recent changes (faster CI)
  • Saving compute time in large test suites
  • Testing hotfixes or feature branches with precision
  1. A valid coverage file (see example below).
  2. A Git diff target branch to compare against (optional, defaults to master).

Simple command usage:

Terminal window
--filter "coverage:file=<path_to_coverage.yml>[,diff=<git_branch>]"

(more commands you can find below in this file)

📄 Example Coverage File Format (we use “coverage.yml” as default one)

Section titled “📄 Example Coverage File Format (we use “coverage.yml” as default one)”

The coverage file defines mappings between changed source files and the tests or tags associated with them. This allows the Coverage Pipe to determine which tests to run based on file changes in Git.

✅ Sample coverage.yml

src/Auth/*.tsx:
- "@S171a8"
- "tag:@auth"
src/Admin/**:
- "@T0922"
src/Checkout/**/*.tsx:
- "tag:@checkaut"

(For now we cover only cases where suiteid/testid/tag can be used as coverage values)

  • Each key is a glob pattern or file path that matches changed files.
  • Each value is a list of: — Test IDs (e.g., @T091e) — Suite IDs (e.g., @S171a8) — Tag references (e.g., tag:@smoke)

When a file matches a key, the corresponding tests are included in the run

  • Use **/*.js patterns to cover folders or extensions.
  • You can mix test IDs and tags freely.
  • Multiple patterns can map to the same test or tag.

Retrieve a list of tests matching your filter (without running them):

Section titled “Retrieve a list of tests matching your filter (without running them):”

If you want to check which tests match your filter without executing the test runner, use the --filter-list option

This is useful for:

  • debugging your filter expression
  • confirming which tests the server will return
  • CI pipelines that only need to inspect affected tests

Examples:

Terminal window
npx @testomatio/reporter run --filter-list "coverage:file=coverage.yml"

with a branch comparison:

Terminal window
npx @testomatio/reporter run --filter-list "coverage:file=coverage/coverage.yml,diff=develop"

Run tests based on changed files (by the default master Git branch):

Section titled “Run tests based on changed files (by the default master Git branch):”

Example:

Terminal window
npx @testomatio/reporter run "npx jest" --filter "coverage:file=coverage.yml"
  • Compare changes to a specific Git branch

Example:

Terminal window
npx @testomatio/reporter run "npx jest" --filter "coverage:file=coverage/coverage.yml,diff=develop"
  • Missing or misspelled coverage file
Terminal window
npx @testomatio/reporter run "npx jest" --filter "coverage:file=no-exist.yml"
  • Invalid Git branch
Terminal window
npx @testomatio/reporter run "npx jest" --filter "coverage:file=coverage.yml,diff=no-such-branch"
  • Missing “file” param
Terminal window
npx @testomatio/reporter run "npx jest" --filter "coverage:diff=main"
OptionGit Command UsedNotes
--filter "coverage:file=coverage.yml,diff=feature"git diff feature --name-onlyCompare to feature
--filter "coverage:file=coverage.yml"git diff master --name-onlyDefaults to master
--filter "coverage:diff=master,file=coverage.yml"git diff master --name-onlyOrder doesn’t matter
--filter "coverage:file=coverage.yml,diff=noexist"❌ Git diff failsInvalid branch
--filter "coverage:file=no-exist.yml"❌ Coverage file not foundFile doesn’t exist
--filter "coverage:filepath=coverage.yml"🚫 Missing required parameter: “file”Invalid key

Under the hood, the Coverage Pipe:

  1. Parses Git diff output to find changed files.
  2. Loads the coverage report to map files to test identifiers.
  3. Matches changed files to impacted tests.
  4. Returns a test ID list to be executed.
  5. If the pipe cannot match any tests:
  • You’ll see: ℹ️ No matching entries in coverage file for provided Git changes.
  • If no tests are found: ℹ️ No tests found for execution based on Git changes.

ℹ️ Looking for more dynamic and fast test execution in CI? The Coverage Pipe is your best starting point 👍.