Tests and coverage
gspot runs your test suite as a check at the push stage, and the check fails when coverage falls below the limits you set. Keep the test runner and its dependencies in your own project.
At level recommended, the coverage checks set no minimum. At level all, lines, branches,
functions, and statements need 80%. A limit you set holds at both levels. For a test runner without a configuration, write a command check.
gspot selects jest when your project depends on jest or has a jest.config.* file; otherwise, run
gspot add jest. Then run the coverage check:
gspot check --only jest/coverageThe check runs Jest in your working tree. Failed tests and missed coverage limits exit with 1. A suite that cannot
load, or a missing report, exits with 2.
To require full function coverage:
gspot set coverage.functions 100Add --scope app to set it for the scope app only. The
settings reference lists every coverage setting.
The Jest configuration reports .only tests, skipped tests, and broken test calls, at both levels.
It reads test functions from @jest/globals.
Vitest
Section titled “Vitest”gspot selects vitest when your project depends on vitest; otherwise, run gspot add vitest. Install Vitest and
its coverage provider in your project. Then run:
gspot check --only vitest/coverageSet the minimums under coverage: lines, branches, functions, and
statements. Vitest reads its own vitest.config.ts.
Python with pytest
Section titled “Python with pytest”gspot selects pytest when your project depends on pytest or has conftest.py or pytest.ini; otherwise, run
gspot add pytest. Install pytest and pytest-cov in the .venv of your project. Then run:
gspot check --only pytest/coveragecoverage.lines sets the line coverage limit. The check runs pytest with --strict-markers
and --strict-config.
The Swift page covers Swift tests and their coverage floors.
Test files
Section titled “Test files”test_files names the files that test lint rules treat as tests, such as the Ruff rules for pytest. It does not take
files out of other checks. Its default covers the usual test folders and file names; the
settings reference lists them.
Your patterns add to the list, and the patterns of a scope add to the root list:
gspot set test_files "e2e/**"