badges/shields · error · InvalidResponse
no tests found
Error message
no tests found
What it means
The Jenkins tests badge service throws InvalidResponse when the Jenkins lastCompletedBuild API JSON contains no action object with a `failCount` property. `json.actions.find(o => 'failCount' in o)` returns undefined, so the service concludes the build produced no test results. It signals that the upstream response is valid JSON but lacks the expected test-report structure.
Source
Thrown at services/jenkins/jenkins-tests.service.js:89
skippedLabel,
isCompact,
}) {
return renderTestResultBadge({
passed,
failed,
skipped,
total,
passedLabel,
failedLabel,
skippedLabel,
isCompact,
})
}
transform({ json }) {
const testsObject = json.actions.find(o => 'failCount' in o)
if (!testsObject) {
throw new InvalidResponse({ prettyMessage: 'no tests found' })
}
return {
passed:
testsObject.totalCount -
(testsObject.failCount + testsObject.skipCount),
failed: testsObject.failCount,
skipped: testsObject.skipCount,
total: testsObject.totalCount,
}
}
async handle(
namedParams,
{
jobUrl,
compact_message: compactMessage,
passed_label: passedLabel,View on GitHub (pinned to 766fd8bc89)
Solutions
- Configure a test result publisher (e.g. 'Publish JUnit test result report') in the Jenkins job so failCount/totalCount appear in build actions.
- Ensure the last completed build actually ran tests (trigger a successful build).
- Point the badge at the specific job that runs tests, not an aggregator/seed job.
Example fix
// Jenkinsfile before
// (no test publishing)
// after
stage('Test') {
steps { sh 'npm test -- --reporter=junit --resultsProcessor junit.xml' }
}
post { always { junit 'junit.xml' } } Defensive patterns
Strategy: try-catch
Validate before calling
// Ensure the Jenkins job publishes test results; check via API before rendering:
const job = await (await fetch(`${jenkinsUrl}/job/${jobName}/lastCompletedBuild/api/json?tree=actions`)).json();
const hasTests = job.actions.some(a => 'failCount' in a);
if (!hasTests) console.warn(`${jobName} has no published test results`); Type guard
function hasTestCounts(actions) {
return Array.isArray(actions) && actions.some(a => a && typeof a === 'object' && 'failCount' in a && 'totalCount' in a);
} Try / catch
try {
const tests = await getJenkinsTestsBadge(job);
} catch (e) {
if (e.name === 'InvalidResponse') {
renderBadge('tests', 'n/a');
} else throw e;
} Prevention
- Always configure a JUnit/xUnit publisher in the Jenkins job
- Check the last build actually reached the test stage
- Point test badges only at jobs whose pipelines publish results
When it happens
Trigger: Fetching /jenkins/tests/<job> where the last completed build has no JUnit/test results published — actions array contains no entry with a failCount key (e.g. build failed before tests ran, no test publisher configured).
Common situations: Jenkins job without the JUnit/pytest/xUnit publisher; last build failed at compile stage so tests never executed; job only builds artifacts; matrix/freestyle job renamed so the URL points at a job without tests.
Related errors
- no public goals
- no coverage data available
- invalid response data from auth endpoint
- unparseable svg response
- unparseable toml response
AI-assisted analysis of badges/shields@766fd8bc89 (2026-08-30).
Data as JSON: /api/errors/687683741b6e38dc.
Report an issue: GitHub.