sf-flow-coverage

Get your Salesforce org ready to deploy Flows as active.
Most production orgs deploy Flows as inactive and activate them by hand, because turning on Deploy processes and flows as active requires 75% Apex test coverage across every active autolaunched Flow and process, and few teams know how far they are from that bar.
sf-flow-coverage shows you the gap and helps you close it: it reports your org-wide Flow coverage and which active Flows have none, generates starter Apex tests for uncovered Flows, adds a per-Flow coverage gate to pull requests so you stay above the threshold once the setting is on, and exports Flow coverage to SonarQube, Cobertura, and lcov so it shows up next to your Apex coverage. Salesforce only checks that the org-wide total stays above 75%, so a single Flow with no tests can still go live.
Table of Contents
Requirements
- Salesforce CLI
- Node.js 22.22 or later
- An authenticated Salesforce org for
readiness, gate, and transform. scaffold works without one, but with one it fills in required fields from the org.
- No
git binary. Git history is read with tsgit, a pure TypeScript git implementation. gate --from and the change counts in readiness still need to run inside a git repository checkout.
Install
sf plugins install [email protected]
Quick start
# 1. Run Apex tests so the org's Flow coverage is current
sf apex run test --test-level RunLocalTests --code-coverage --wait 60 --target-org prod
# 2. See how far you are from 75%, and which Flows to cover first
sf flowcov readiness --target-org prod --since "6 months ago"
# 3. Generate starter Apex tests for every uncovered Flow
sf flowcov scaffold --uncovered --target-org prod
# 4. In CI, after deploying the branch and running tests, require coverage for each changed Flow
sf flowcov gate --target-org ci-sandbox --from origin/main --to HEAD
# 5. Publish Flow coverage to SonarQube next to your Apex coverage
sf flowcov transform --target-org ci-sandbox --format sonar # writes coverage/flow-coverage-sonar.xml
For the Apex side of step 5, see Alongside Apex coverage.
How coverage is measured

| Term | Counts |
|---|
| Cactive | Active versions an Apex test ran |
| Clatest | Latest inactive versions an Apex test ran |
| Uactive | Active versions no Apex test ran |
Only counted process types are included (see below). Screen Flows, older inactive versions, and latest inactive versions no test ran are ignored, so they never lower the percentage. At or above the threshold, Flows can deploy as active.
For example, an org with 8 active Flows that have a test, 2 active Flows without one, and 1 latest inactive version that has a test is at (8 + 1) ÷ (8 + 1 + 2) = 81.8%. Element coverage doesn't change this number: a Flow counts as covered once any test runs it.