{"record":{"id":"687683741b6e38dc","repo":"badges/shields","slug":"no-tests-found","errorCode":null,"errorMessage":"no tests found","messagePattern":"no tests found","errorType":"exception","errorClass":"InvalidResponse","httpStatus":424,"severity":"error","filePath":"services/jenkins/jenkins-tests.service.js","lineNumber":89,"sourceCode":"    skippedLabel,\n    isCompact,\n  }) {\n    return renderTestResultBadge({\n      passed,\n      failed,\n      skipped,\n      total,\n      passedLabel,\n      failedLabel,\n      skippedLabel,\n      isCompact,\n    })\n  }\n\n  transform({ json }) {\n    const testsObject = json.actions.find(o => 'failCount' in o)\n    if (!testsObject) {\n      throw new InvalidResponse({ prettyMessage: 'no tests found' })\n    }\n\n    return {\n      passed:\n        testsObject.totalCount -\n        (testsObject.failCount + testsObject.skipCount),\n      failed: testsObject.failCount,\n      skipped: testsObject.skipCount,\n      total: testsObject.totalCount,\n    }\n  }\n\n  async handle(\n    namedParams,\n    {\n      jobUrl,\n      compact_message: compactMessage,\n      passed_label: passedLabel,","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/badges/shields/blob/766fd8bc89a90b8534dc573ab72dec30215ab1ec/services/jenkins/jenkins-tests.service.js#L71-L107","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// Jenkinsfile before\n// (no test publishing)\n// after\nstage('Test') {\n  steps { sh 'npm test -- --reporter=junit --resultsProcessor junit.xml' }\n}\npost { always { junit 'junit.xml' } }","handlingStrategy":"try-catch","validationCode":"// Ensure the Jenkins job publishes test results; check via API before rendering:\nconst job = await (await fetch(`${jenkinsUrl}/job/${jobName}/lastCompletedBuild/api/json?tree=actions`)).json();\nconst hasTests = job.actions.some(a => 'failCount' in a);\nif (!hasTests) console.warn(`${jobName} has no published test results`);","typeGuard":"function hasTestCounts(actions) {\n  return Array.isArray(actions) && actions.some(a => a && typeof a === 'object' && 'failCount' in a && 'totalCount' in a);\n}","tryCatchPattern":"try {\n  const tests = await getJenkinsTestsBadge(job);\n} catch (e) {\n  if (e.name === 'InvalidResponse') {\n    renderBadge('tests', 'n/a');\n  } else throw e;\n}","preventionTips":["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"],"tags":["jenkins","tests","invalid-response","missing-data"],"backgroundTag":"missing-test-report-data","analyzedSha":"766fd8bc89a90b8534dc573ab72dec30215ab1ec","analyzedAt":"2026-08-30T01:40:27.499Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}