@testream/jest-reporter 1.1.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,6 +11,7 @@ npm install --save-dev @testream/jest-reporter
11
11
  ```javascript
12
12
  // jest.config.js
13
13
  module.exports = {
14
+ testLocationInResults: true,
14
15
  reporters: [
15
16
  'default',
16
17
  [
@@ -24,4 +25,9 @@ module.exports = {
24
25
  };
25
26
  ```
26
27
 
28
+ `testLocationInResults: true` is recommended because it gives the reporter exact
29
+ line metadata. If it is not enabled, the reporter will still try to infer source
30
+ snippets from the test file, but that fallback is less reliable than Jest's
31
+ built-in location data.
32
+
27
33
  Need more configuration options? See the full guide at https://docs.testream.app/reporters/jest.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- (()=>{"use strict";var e={580:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});const n=r(896);const i=r(928);class GenerateCtrfReport{constructor(e,t,r){var i,o,s,a,u,l,c,d,p,f,m,h,b,_,y,R,v,T,U;this.reporterName="jest-ctrf-json-reporter";this.defaultOutputFile="ctrf-report.json";this.defaultOutputDir="ctrf";this.filename=this.defaultOutputFile;this.reporterConfigOptions={outputFile:(i=t===null||t===void 0?void 0:t.outputFile)!==null&&i!==void 0?i:this.defaultOutputFile,outputDir:(o=t===null||t===void 0?void 0:t.outputDir)!==null&&o!==void 0?o:this.defaultOutputDir,minimal:(s=t===null||t===void 0?void 0:t.minimal)!==null&&s!==void 0?s:false,testType:(a=t.testType)!==null&&a!==void 0?a:"unit",appName:(u=t===null||t===void 0?void 0:t.appName)!==null&&u!==void 0?u:undefined,appVersion:(l=t===null||t===void 0?void 0:t.appVersion)!==null&&l!==void 0?l:undefined,osPlatform:(c=t===null||t===void 0?void 0:t.osPlatform)!==null&&c!==void 0?c:undefined,osRelease:(d=t===null||t===void 0?void 0:t.osRelease)!==null&&d!==void 0?d:undefined,osVersion:(p=t===null||t===void 0?void 0:t.osVersion)!==null&&p!==void 0?p:undefined,buildName:(f=t===null||t===void 0?void 0:t.buildName)!==null&&f!==void 0?f:undefined,buildNumber:(m=t===null||t===void 0?void 0:t.buildNumber)!==null&&m!==void 0?m:undefined,buildUrl:(h=t===null||t===void 0?void 0:t.buildUrl)!==null&&h!==void 0?h:undefined,repositoryName:(b=t===null||t===void 0?void 0:t.repositoryName)!==null&&b!==void 0?b:undefined,repositoryUrl:(_=t===null||t===void 0?void 0:t.repositoryUrl)!==null&&_!==void 0?_:undefined,branchName:(y=t===null||t===void 0?void 0:t.branchName)!==null&&y!==void 0?y:undefined,testEnvironment:(R=t===null||t===void 0?void 0:t.testEnvironment)!==null&&R!==void 0?R:undefined};this.ctrfReport={results:{tool:{name:"jest"},summary:{tests:0,passed:0,failed:0,pending:0,skipped:0,other:0,start:0,stop:0},tests:[]}};this.ctrfEnvironment={};if(((v=this.reporterConfigOptions)===null||v===void 0?void 0:v.outputFile)!==undefined)this.setFilename(this.reporterConfigOptions.outputFile);if(!n.existsSync((T=this.reporterConfigOptions.outputDir)!==null&&T!==void 0?T:this.defaultOutputDir)){n.mkdirSync((U=this.reporterConfigOptions.outputDir)!==null&&U!==void 0?U:this.defaultOutputDir,{recursive:true})}}onRunStart(){var e;this.ctrfReport.results.summary.start=Date.now();this.setEnvironmentDetails((e=this.reporterConfigOptions)!==null&&e!==void 0?e:{});if(this.hasEnvironmentDetails(this.ctrfEnvironment)){this.ctrfReport.results.environment=this.ctrfEnvironment}}onTestStart(){}onTestResult(e,t){this.updateCtrfTestResultsFromTestResult(t);this.updateTotalsFromTestResult(t)}onRunComplete(){this.ctrfReport.results.summary.stop=Date.now();this.writeReportToFile(this.ctrfReport)}setFilename(e){if(e.endsWith(".json")){this.filename=e}else{this.filename=`${e}.json`}}updateCtrfTestResultsFromTestResult(e){e.testResults.forEach((t=>{var r,n,i,o;const s={name:t.fullName,duration:(r=t.duration)!==null&&r!==void 0?r:0,status:this.mapStatus(t.status)};if(this.reporterConfigOptions.minimal===false){s.message=this.extractFailureDetails(t).message;s.trace=this.extractFailureDetails(t).trace;s.rawStatus=t.status;s.type=(n=this.reporterConfigOptions.testType)!==null&&n!==void 0?n:"unit";s.filePath=e.testFilePath;s.retries=((i=t.invocations)!==null&&i!==void 0?i:1)-1;s.flaky=t.status==="passed"&&((o=t.invocations)!==null&&o!==void 0?o:1)-1>0;s.suite=this.buildSuitePath(e,t)}this.ctrfReport.results.tests.push(s)}))}extractFailureDetails(e){var t;const r=/^\s{4}at/mu;const n=/\x1b\[\d+m/gmu;if(e.status==="failed"&&e.failureMessages!==undefined){const i={};if(e.failureMessages!==undefined){const t=e.failureMessages.join("\n");const o=t.match(r);i.message=t.slice(0,o===null||o===void 0?void 0:o.index).replace(n,"");i.trace=t.slice(o===null||o===void 0?void 0:o.index).split("\n").map((e=>e.trim())).join("\n")}if(e.failureDetails!==undefined){i.trace=(t=i.trace)===null||t===void 0?void 0:t.concat("\n\n",e.failureDetails.join("\n"))}return i}return{}}updateTotalsFromTestResult(e){e.testResults.forEach((e=>{const t=this.mapStatus(e.status);this.ctrfReport.results.summary[t]++;this.ctrfReport.results.summary.tests++}))}mapStatus(e){switch(e){case"passed":return"passed";case"failed":return"failed";case"skipped":return"skipped";case"pending":return"pending";case"todo":case"disabled":case"focused":default:return"other"}}setEnvironmentDetails(e){if(e.appName!==undefined){this.ctrfEnvironment.appName=e.appName}if(e.appVersion!==undefined){this.ctrfEnvironment.appVersion=e.appVersion}if(e.osPlatform!==undefined){this.ctrfEnvironment.osPlatform=e.osPlatform}if(e.osRelease!==undefined){this.ctrfEnvironment.osRelease=e.osRelease}if(e.osVersion!==undefined){this.ctrfEnvironment.osVersion=e.osVersion}if(e.buildName!==undefined){this.ctrfEnvironment.buildName=e.buildName}if(e.buildNumber!==undefined){this.ctrfEnvironment.buildNumber=e.buildNumber}if(e.buildUrl!==undefined){this.ctrfEnvironment.buildUrl=e.buildUrl}if(e.repositoryName!==undefined){this.ctrfEnvironment.repositoryName=e.repositoryName}if(e.repositoryUrl!==undefined){this.ctrfEnvironment.repositoryUrl=e.repositoryUrl}if(e.branchName!==undefined){this.ctrfEnvironment.branchName=e.branchName}if(e.testEnvironment!==undefined){this.ctrfEnvironment.testEnvironment=e.testEnvironment}}hasEnvironmentDetails(e){return Object.keys(e).length>0}buildSuitePath(e,t){var r;const n=(r=e.testFilePath.split("/").pop())!==null&&r!==void 0?r:"";const i=[n,...t.ancestorTitles];return i.join(" > ")}writeReportToFile(e){var t;const r=i.join((t=this.reporterConfigOptions.outputDir)!==null&&t!==void 0?t:this.defaultOutputDir,this.filename);const o=JSON.stringify(e,null,2);try{n.writeFileSync(r,o+"\n");console.log(`${this.reporterName}: successfully written ctrf json to %s/%s`,this.reporterConfigOptions.outputDir,this.filename)}catch(e){console.error(`Error writing ctrf json report:, ${String(e)}`)}}}t["default"]=GenerateCtrfReport},764:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var n=r(580);Object.defineProperty(t,"default",{enumerable:true,get:function(){return n.default}})},406:(e,t)=>{Object.defineProperty(t,"__esModule",{value:true});t.detectCIContext=detectCIContext;function removePrefix(e,t){if(!e){return undefined}return e.startsWith(t)?e.slice(t.length):e}function readEnvironment(){const e=globalThis;return e.process?.env??{}}function buildGithubRepositoryUrl(e){if(!e.GITHUB_SERVER_URL||!e.GITHUB_REPOSITORY){return undefined}return`${e.GITHUB_SERVER_URL}/${e.GITHUB_REPOSITORY}`}function buildGithubBuildUrl(e){if(!e.GITHUB_SERVER_URL||!e.GITHUB_REPOSITORY||!e.GITHUB_RUN_ID){return undefined}return`${e.GITHUB_SERVER_URL}/${e.GITHUB_REPOSITORY}/actions/runs/${e.GITHUB_RUN_ID}`}function detectGitHubBranch(e){if(e.GITHUB_HEAD_REF){return e.GITHUB_HEAD_REF}if(e.GITHUB_REF?.startsWith("refs/heads/")){return e.GITHUB_REF_NAME??removePrefix(e.GITHUB_REF,"refs/heads/")}return undefined}function detectGitHubActionsContext(e){return{branch:detectGitHubBranch(e),commitSha:e.GITHUB_SHA,repositoryUrl:buildGithubRepositoryUrl(e),buildNumber:e.GITHUB_RUN_NUMBER,buildUrl:buildGithubBuildUrl(e)}}function detectGitLabContext(e){return{branch:e.CI_COMMIT_BRANCH||e.CI_MERGE_REQUEST_SOURCE_BRANCH_NAME,commitSha:e.CI_COMMIT_SHA,repositoryUrl:e.CI_PROJECT_URL,buildNumber:e.CI_PIPELINE_IID,buildUrl:e.CI_PIPELINE_URL}}function detectAzurePipelinesContext(e){return{branch:removePrefix(e.BUILD_SOURCEBRANCH,"refs/heads/"),commitSha:e.BUILD_SOURCEVERSION,repositoryUrl:e.BUILD_REPOSITORY_URI,buildNumber:e.BUILD_BUILDNUMBER,buildUrl:e.SYSTEM_TEAMFOUNDATIONCOLLECTIONURI&&e.SYSTEM_TEAMPROJECT&&e.BUILD_BUILDID?`${e.SYSTEM_TEAMFOUNDATIONCOLLECTIONURI}${e.SYSTEM_TEAMPROJECT}/_build/results?buildId=${e.BUILD_BUILDID}`:undefined}}function detectCircleCIContext(e){return{branch:e.CIRCLE_BRANCH,commitSha:e.CIRCLE_SHA1,repositoryUrl:e.CIRCLE_REPOSITORY_URL,buildNumber:e.CIRCLE_BUILD_NUM,buildUrl:e.CIRCLE_BUILD_URL}}function detectJenkinsContext(e){return{branch:removePrefix(e.GIT_BRANCH,"origin/"),commitSha:e.GIT_COMMIT,repositoryUrl:e.GIT_URL,buildNumber:e.BUILD_NUMBER,buildUrl:e.BUILD_URL}}function detectBitbucketContext(e){return{branch:e.BITBUCKET_BRANCH,commitSha:e.BITBUCKET_COMMIT,repositoryUrl:e.BITBUCKET_GIT_HTTP_ORIGIN,buildNumber:e.BITBUCKET_BUILD_NUMBER,buildUrl:e.BITBUCKET_REPO_FULL_NAME&&e.BITBUCKET_BUILD_NUMBER?`https://bitbucket.org/${e.BITBUCKET_REPO_FULL_NAME}/pipelines/results/${e.BITBUCKET_BUILD_NUMBER}`:undefined}}const r=[{isMatch:e=>e.GITHUB_ACTIONS==="true",detect:detectGitHubActionsContext},{isMatch:e=>e.GITLAB_CI==="true",detect:detectGitLabContext},{isMatch:e=>e.TF_BUILD==="True",detect:detectAzurePipelinesContext},{isMatch:e=>e.CIRCLECI==="true",detect:detectCircleCIContext},{isMatch:e=>Boolean(e.JENKINS_URL),detect:detectJenkinsContext},{isMatch:e=>Boolean(e.BITBUCKET_BUILD_NUMBER),detect:detectBitbucketContext}];function detectCIContext(){const e=readEnvironment();for(const t of r){if(t.isMatch(e)){return t.detect(e)}}return{}}},827:(e,t)=>{Object.defineProperty(t,"__esModule",{value:true})},322:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;var i=Object.getOwnPropertyDescriptor(t,r);if(!i||("get"in i?!t.__esModule:i.writable||i.configurable)){i={enumerable:true,get:function(){return t[r]}}}Object.defineProperty(e,n,i)}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var i=this&&this.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))n(t,e,r)};Object.defineProperty(t,"__esModule",{value:true});t.ensureReportId=t.mapAttachmentsToTestResults=t.uploadArtifacts=t.uploadTestRun=t.detectCIContext=void 0;i(r(827),t);var o=r(406);Object.defineProperty(t,"detectCIContext",{enumerable:true,get:function(){return o.detectCIContext}});var s=r(969);Object.defineProperty(t,"uploadTestRun",{enumerable:true,get:function(){return s.uploadTestRun}});Object.defineProperty(t,"uploadArtifacts",{enumerable:true,get:function(){return s.uploadArtifacts}});Object.defineProperty(t,"mapAttachmentsToTestResults",{enumerable:true,get:function(){return s.mapAttachmentsToTestResults}});Object.defineProperty(t,"ensureReportId",{enumerable:true,get:function(){return s.ensureReportId}})},969:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t.ensureReportId=ensureReportId;t.uploadTestRun=uploadTestRun;t.mapAttachmentsToTestResults=mapAttachmentsToTestResults;t.uploadArtifacts=uploadArtifacts;const n=r(406);const i="https://test-manager-backend.fly.dev";function ensureReportId(e){if(typeof e.reportId==="string"&&e.reportId.trim().length>0){return e.reportId}const t=crypto.randomUUID();e.reportId=t;return t}function resolveApiUrl(e){const t=normalizeApiUrl(e);if(t){return t}const r=getEnvApiUrl();if(r){return r}return i}function getEnvApiUrl(){if(typeof process==="undefined"||!process?.env){return undefined}return normalizeApiUrl(process.env.TESTREAM_API_URL)}function normalizeApiUrl(e){if(!e){return undefined}const t=e.trim();if(!t){return undefined}return t.replace(/\/+$/,"")}function isReportAlreadyExistsConflict(e){return e.errorCode==="report_already_exists"}function formatUploadError(e){const t=e.detail||e.title||e.rawBody||"Unknown error";const r=e.errorCode?`, code=${e.errorCode}`:"";return`Upload failed (HTTP ${e.statusCode}${r}): ${t}`}async function parseHttpError(e){const t=await e.text();const r=e.headers.get("content-type")||"";if(r.toLowerCase().includes("json")&&t.trim().length>0){try{const r=JSON.parse(t);return{statusCode:e.status,title:r.title,detail:r.detail||r.details||r.error,errorCode:r.errorCode,rawBody:t}}catch{}}return{statusCode:e.status,rawBody:t}}function resolveUploadContext(e){const t=(0,n.detectCIContext)();return{commitSha:e.commitSha??t.commitSha,branch:e.branch??t.branch,repositoryUrl:e.repositoryUrl??t.repositoryUrl,buildName:e.buildName,buildNumber:e.buildNumber??t.buildNumber,buildUrl:e.buildUrl??t.buildUrl,testEnvironment:e.testEnvironment,appName:e.appName,appVersion:e.appVersion,testType:e.testType}}async function uploadTestRun(e){const{report:t,apiKey:r}=e;const n=resolveApiUrl(e.apiUrl);const i=ensureReportId(t);const o=resolveUploadContext(e);const s={report:t,reportId:i,...o};console.log("Uploading test results...");let a;try{a=await fetch(`${n}/api/v1/ingest`,{method:"POST",headers:{"X-API-KEY":r,"Content-Type":"application/json"},body:JSON.stringify(s)})}catch(e){const t=e instanceof Error?e.message:String(e);const r=`Connection failed: ${t}`;console.error(r);return{success:false,reportId:i,error:r}}if(!a.ok){const e=await parseHttpError(a);if(a.status===409&&isReportAlreadyExistsConflict(e)){console.warn("Report already exists (workflow may have been re-run)");return{success:true,reportId:i,summary:{passed:t.results.summary.passed,failed:t.results.summary.failed,skipped:t.results.summary.skipped,total:t.results.summary.tests},alreadyExists:true,statusCode:e.statusCode,errorCode:e.errorCode}}const r=formatUploadError(e);console.error(r);return{success:false,reportId:i,error:r,statusCode:e.statusCode,errorCode:e.errorCode,errorDetail:e.detail||e.rawBody}}const u=await a.json();console.log(`✓ Test results uploaded successfully`);console.log(` Report ID: ${u.reportId}`);console.log(` Test Run ID: ${u.testRunId}`);console.log(` Tests: ${u.summary.passed}/${u.summary.total} passed`);return{success:true,reportId:u.reportId,testRunId:u.testRunId,summary:{passed:u.summary.passed,failed:u.summary.failed,skipped:u.summary.skipped,total:u.summary.total},testResults:u.testResults}}function mapAttachmentsToTestResults(e,t){const r=new Map;for(const e of t){const t=r.get(e.name)??[];t.push(e.id);r.set(e.name,t)}const n=[];for(const t of e){const e=r.get(t.name);const i=e?.shift();if(!t.attachments||t.attachments.length===0){continue}if(!i){console.warn(`Skipping artifact upload: could not match test result for "${t.name}"`);continue}n.push({testResultId:i,attachments:t.attachments})}return n}async function uploadArtifacts(e){const{reportId:t,apiKey:r,testResults:n}=e;const i=resolveApiUrl(e.apiUrl);let o=0;for(const e of n){for(const n of e.attachments){try{const s=await uploadSingleArtifact({testResultId:e.testResultId,attachment:n,reportId:t,apiKey:r,apiUrl:i});if(s)o++}catch(e){const t=e instanceof Error?e.message:String(e);console.error(`Failed to upload artifact ${n.name}: ${t}`)}}}if(o>0){console.log(`✓ Uploaded ${o} artifact(s)`)}return o}async function uploadSingleArtifact(e){const{testResultId:t,attachment:n,reportId:i,apiKey:o,apiUrl:s}=e;const a=await Promise.resolve().then(r.t.bind(r,943,23));const u=await Promise.resolve().then(r.t.bind(r,928,23));const l=u.resolve(n.path);try{await a.access(l)}catch{console.warn(`Artifact not found: ${u.basename(l)}`);return false}let c;let d;const p=u.basename(l);const f=n.contentType||"application/octet-stream";try{c=await a.readFile(l);d=c.byteLength}catch(e){const t=e instanceof Error?e.message:String(e);throw new Error(`Failed to read file: ${t}`)}try{return await uploadWithPresignedUrl({testResultId:t,reportId:i,apiKey:o,apiUrl:s,attachmentName:n.name,fileName:p,contentType:f,sizeBytes:d,fileBuffer:c})}catch(e){if(!(e instanceof LegacyUploadRequiredError)){throw e}return await uploadWithLegacyEndpoint({testResultId:t,attachmentName:n.name,reportId:i,apiKey:o,apiUrl:s,fileName:p,contentType:f,fileBuffer:c})}}class LegacyUploadRequiredError extends Error{constructor(){super("Legacy upload endpoint required")}}async function uploadWithPresignedUrl(e){const{testResultId:t,reportId:r,apiKey:n,apiUrl:i,attachmentName:o,fileName:s,contentType:a,sizeBytes:u,fileBuffer:l}=e;const c={testResultId:t,ctrfAttachmentName:o,fileName:s,contentType:a,sizeBytes:u};const d=await fetch(`${i}/api/v1/artifacts/${r}/upload-url`,{method:"POST",headers:{"X-API-KEY":n,"Content-Type":"application/json"},body:JSON.stringify(c)});if(shouldFallbackToLegacyUpload(d.status)){throw new LegacyUploadRequiredError}if(!d.ok){const e=await d.text();throw new Error(`Failed to create direct upload URL (HTTP ${d.status}): ${e}`)}const p=await d.json();const f={...p.requiredHeaders??{}};if(!hasHeaderIgnoreCase(f,"Content-Type")){f["Content-Type"]=a}const m=await fetch(p.uploadUrl,{method:"PUT",headers:f,body:l});if(!m.ok){const e=await m.text();throw new Error(`Direct artifact upload failed (HTTP ${m.status}): ${e}`)}const h={testResultId:t,ctrfAttachmentName:o,fileName:s,contentType:a,sizeBytes:u,storageKey:p.storageKey};const b=await fetch(`${i}/api/v1/artifacts/${r}/complete`,{method:"POST",headers:{"X-API-KEY":n,"Content-Type":"application/json"},body:JSON.stringify(h)});if(!b.ok){const e=await b.text();throw new Error(`Failed to finalize artifact upload (HTTP ${b.status}): ${e}`)}return true}async function uploadWithLegacyEndpoint(e){const{testResultId:t,attachmentName:r,reportId:n,apiKey:i,apiUrl:o,fileName:s,contentType:a,fileBuffer:u}=e;const l=new Blob([new Uint8Array(u)],{type:a});const c=new FormData;c.append("testResultId",t);c.append("ctrfAttachmentName",r);c.append("file",l,s);const d=await fetch(`${o}/api/v1/artifacts/${n}`,{method:"POST",headers:{"X-API-KEY":i},body:c});if(!d.ok){const e=await d.text();throw new Error(`Legacy artifact upload failed (HTTP ${d.status}): ${e}`)}return true}function shouldFallbackToLegacyUpload(e){return e===404||e===405||e===501}function hasHeaderIgnoreCase(e,t){const r=t.toLowerCase();return Object.keys(e).some((e=>e.toLowerCase()===r))}},665:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;var i=Object.getOwnPropertyDescriptor(t,r);if(!i||("get"in i?!t.__esModule:i.writable||i.configurable)){i={enumerable:true,get:function(){return t[r]}}}Object.defineProperty(e,n,i)}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var o=this&&this.__importStar||function(){var ownKeys=function(e){ownKeys=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r))t[t.length]=r;return t};return ownKeys(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=ownKeys(e),o=0;o<r.length;o++)if(r[o]!=="default")n(t,e,r[o]);i(t,e);return t}}();var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});t.TestreamJestReporter=void 0;const a=s(r(764));const u=o(r(943));const l=o(r(928));const c=r(10);class TestreamJestReporter{constructor(e,t,r={}){this.outputDir="ctrf";this.outputFile="ctrf-report.json";this.config={uploadEnabled:true,failOnUploadError:false,apiKey:"",...t};const n={outputDir:this.outputDir,outputFile:this.outputFile};if(this.config.testEnvironment)n.testEnvironment=this.config.testEnvironment;if(this.config.appName)n.appName=this.config.appName;if(this.config.appVersion)n.appVersion=this.config.appVersion;if(this.config.buildName)n.buildName=this.config.buildName;if(this.config.buildNumber)n.buildNumber=this.config.buildNumber;if(this.config.buildUrl)n.buildUrl=this.config.buildUrl;if(this.config.testType)n.testType=this.config.testType;if(this.config.branch)n.branchName=this.config.branch;if(this.config.commitSha)n.commit=this.config.commitSha;this.ctrfReporter=new a.default(e,n,r)}onRunStart(e,t){if(this.ctrfReporter.onRunStart){return this.ctrfReporter.onRunStart()}}onTestStart(e){if(this.ctrfReporter.onTestStart){return this.ctrfReporter.onTestStart()}}onTestResult(e,t,r){if(this.ctrfReporter.onTestResult){return this.ctrfReporter.onTestResult(e,t)}}async onRunComplete(e,t){if(this.ctrfReporter.onRunComplete){this.ctrfReporter.onRunComplete()}const r=await this.readCTRFReport();if(!r){console.error("Failed to read CTRF report, skipping upload");return}console.info(`CTRF report written to: ${l.join(this.outputDir,this.outputFile)}`);if(this.config.uploadEnabled&&this.config.apiKey){await this.uploadReport(r)}}async readCTRFReport(){const e=l.join(this.outputDir,this.outputFile);try{const t=await u.readFile(e,"utf-8");const r=JSON.parse(t);r.results.tool.name="jest";r.generatedBy="@testream/jest-reporter";return r}catch(t){console.error(`Failed to read CTRF report from ${e}: ${t instanceof Error?t.message:String(t)}`);return null}}async uploadReport(e){const t=await(0,c.uploadToApi)({report:e,apiKey:this.config.apiKey,branch:this.config.branch,commitSha:this.config.commitSha,repositoryUrl:this.config.repositoryUrl,buildName:this.config.buildName,buildNumber:this.config.buildNumber,buildUrl:this.config.buildUrl,testEnvironment:this.config.testEnvironment,appName:this.config.appName,appVersion:this.config.appVersion,testType:this.config.testType});if(!t.success&&this.config.failOnUploadError){throw new Error(`Upload failed: ${t.error}`)}}}t.TestreamJestReporter=TestreamJestReporter;t["default"]=TestreamJestReporter},10:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t.detectGitContext=void 0;t.uploadToApi=uploadToApi;const n=r(322);async function uploadToApi(e){return(0,n.uploadTestRun)({report:e.report,apiKey:e.apiKey,apiUrl:e.apiUrl,commitSha:e.commitSha,branch:e.branch,repositoryUrl:e.repositoryUrl,buildName:e.buildName,buildNumber:e.buildNumber,buildUrl:e.buildUrl,testEnvironment:e.testEnvironment,appName:e.appName,appVersion:e.appVersion,testType:e.testType})}t.detectGitContext=n.detectCIContext},896:e=>{e.exports=require("fs")},943:e=>{e.exports=require("fs/promises")},928:e=>{e.exports=require("path")}};var t={};function __nccwpck_require__(r){var n=t[r];if(n!==undefined){return n.exports}var i=t[r]={exports:{}};var o=true;try{e[r].call(i.exports,i,i.exports,__nccwpck_require__);o=false}finally{if(o)delete t[r]}return i.exports}(()=>{var e=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__;var t;__nccwpck_require__.t=function(r,n){if(n&1)r=this(r);if(n&8)return r;if(typeof r==="object"&&r){if(n&4&&r.__esModule)return r;if(n&16&&typeof r.then==="function")return r}var i=Object.create(null);__nccwpck_require__.r(i);var o={};t=t||[null,e({}),e([]),e(e)];for(var s=n&2&&r;typeof s=="object"&&!~t.indexOf(s);s=e(s)){Object.getOwnPropertyNames(s).forEach((e=>o[e]=()=>r[e]))}o["default"]=()=>r;__nccwpck_require__.d(i,o);return i}})();(()=>{__nccwpck_require__.d=(e,t)=>{for(var r in t){if(__nccwpck_require__.o(t,r)&&!__nccwpck_require__.o(e,r)){Object.defineProperty(e,r,{enumerable:true,get:t[r]})}}}})();(()=>{__nccwpck_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})();(()=>{__nccwpck_require__.r=e=>{if(typeof Symbol!=="undefined"&&Symbol.toStringTag){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}Object.defineProperty(e,"__esModule",{value:true})}})();if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var r={};(()=>{var e=r;Object.defineProperty(e,"__esModule",{value:true});e.TestreamJestReporter=e["default"]=void 0;var t=__nccwpck_require__(665);Object.defineProperty(e,"default",{enumerable:true,get:function(){return t.TestreamJestReporter}});var n=__nccwpck_require__(665);Object.defineProperty(e,"TestreamJestReporter",{enumerable:true,get:function(){return n.TestreamJestReporter}})})();module.exports=r})();
1
+ (()=>{"use strict";var e={580:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});const n=r(896);const i=r(928);class GenerateCtrfReport{constructor(e,t,r){var i,o,s,a,u,l,c,d,f,p,h,m,b,T,_,R,y,g,v;this.reporterName="jest-ctrf-json-reporter";this.defaultOutputFile="ctrf-report.json";this.defaultOutputDir="ctrf";this.filename=this.defaultOutputFile;this.reporterConfigOptions={outputFile:(i=t===null||t===void 0?void 0:t.outputFile)!==null&&i!==void 0?i:this.defaultOutputFile,outputDir:(o=t===null||t===void 0?void 0:t.outputDir)!==null&&o!==void 0?o:this.defaultOutputDir,minimal:(s=t===null||t===void 0?void 0:t.minimal)!==null&&s!==void 0?s:false,testType:(a=t.testType)!==null&&a!==void 0?a:"unit",appName:(u=t===null||t===void 0?void 0:t.appName)!==null&&u!==void 0?u:undefined,appVersion:(l=t===null||t===void 0?void 0:t.appVersion)!==null&&l!==void 0?l:undefined,osPlatform:(c=t===null||t===void 0?void 0:t.osPlatform)!==null&&c!==void 0?c:undefined,osRelease:(d=t===null||t===void 0?void 0:t.osRelease)!==null&&d!==void 0?d:undefined,osVersion:(f=t===null||t===void 0?void 0:t.osVersion)!==null&&f!==void 0?f:undefined,buildName:(p=t===null||t===void 0?void 0:t.buildName)!==null&&p!==void 0?p:undefined,buildNumber:(h=t===null||t===void 0?void 0:t.buildNumber)!==null&&h!==void 0?h:undefined,buildUrl:(m=t===null||t===void 0?void 0:t.buildUrl)!==null&&m!==void 0?m:undefined,repositoryName:(b=t===null||t===void 0?void 0:t.repositoryName)!==null&&b!==void 0?b:undefined,repositoryUrl:(T=t===null||t===void 0?void 0:t.repositoryUrl)!==null&&T!==void 0?T:undefined,branchName:(_=t===null||t===void 0?void 0:t.branchName)!==null&&_!==void 0?_:undefined,testEnvironment:(R=t===null||t===void 0?void 0:t.testEnvironment)!==null&&R!==void 0?R:undefined};this.ctrfReport={results:{tool:{name:"jest"},summary:{tests:0,passed:0,failed:0,pending:0,skipped:0,other:0,start:0,stop:0},tests:[]}};this.ctrfEnvironment={};if(((y=this.reporterConfigOptions)===null||y===void 0?void 0:y.outputFile)!==undefined)this.setFilename(this.reporterConfigOptions.outputFile);if(!n.existsSync((g=this.reporterConfigOptions.outputDir)!==null&&g!==void 0?g:this.defaultOutputDir)){n.mkdirSync((v=this.reporterConfigOptions.outputDir)!==null&&v!==void 0?v:this.defaultOutputDir,{recursive:true})}}onRunStart(){var e;this.ctrfReport.results.summary.start=Date.now();this.setEnvironmentDetails((e=this.reporterConfigOptions)!==null&&e!==void 0?e:{});if(this.hasEnvironmentDetails(this.ctrfEnvironment)){this.ctrfReport.results.environment=this.ctrfEnvironment}}onTestStart(){}onTestResult(e,t){this.updateCtrfTestResultsFromTestResult(t);this.updateTotalsFromTestResult(t)}onRunComplete(){this.ctrfReport.results.summary.stop=Date.now();this.writeReportToFile(this.ctrfReport)}setFilename(e){if(e.endsWith(".json")){this.filename=e}else{this.filename=`${e}.json`}}updateCtrfTestResultsFromTestResult(e){e.testResults.forEach((t=>{var r,n,i,o;const s={name:t.fullName,duration:(r=t.duration)!==null&&r!==void 0?r:0,status:this.mapStatus(t.status)};if(this.reporterConfigOptions.minimal===false){s.message=this.extractFailureDetails(t).message;s.trace=this.extractFailureDetails(t).trace;s.rawStatus=t.status;s.type=(n=this.reporterConfigOptions.testType)!==null&&n!==void 0?n:"unit";s.filePath=e.testFilePath;s.retries=((i=t.invocations)!==null&&i!==void 0?i:1)-1;s.flaky=t.status==="passed"&&((o=t.invocations)!==null&&o!==void 0?o:1)-1>0;s.suite=this.buildSuitePath(e,t)}this.ctrfReport.results.tests.push(s)}))}extractFailureDetails(e){var t;const r=/^\s{4}at/mu;const n=/\x1b\[\d+m/gmu;if(e.status==="failed"&&e.failureMessages!==undefined){const i={};if(e.failureMessages!==undefined){const t=e.failureMessages.join("\n");const o=t.match(r);i.message=t.slice(0,o===null||o===void 0?void 0:o.index).replace(n,"");i.trace=t.slice(o===null||o===void 0?void 0:o.index).split("\n").map((e=>e.trim())).join("\n")}if(e.failureDetails!==undefined){i.trace=(t=i.trace)===null||t===void 0?void 0:t.concat("\n\n",e.failureDetails.join("\n"))}return i}return{}}updateTotalsFromTestResult(e){e.testResults.forEach((e=>{const t=this.mapStatus(e.status);this.ctrfReport.results.summary[t]++;this.ctrfReport.results.summary.tests++}))}mapStatus(e){switch(e){case"passed":return"passed";case"failed":return"failed";case"skipped":return"skipped";case"pending":return"pending";case"todo":case"disabled":case"focused":default:return"other"}}setEnvironmentDetails(e){if(e.appName!==undefined){this.ctrfEnvironment.appName=e.appName}if(e.appVersion!==undefined){this.ctrfEnvironment.appVersion=e.appVersion}if(e.osPlatform!==undefined){this.ctrfEnvironment.osPlatform=e.osPlatform}if(e.osRelease!==undefined){this.ctrfEnvironment.osRelease=e.osRelease}if(e.osVersion!==undefined){this.ctrfEnvironment.osVersion=e.osVersion}if(e.buildName!==undefined){this.ctrfEnvironment.buildName=e.buildName}if(e.buildNumber!==undefined){this.ctrfEnvironment.buildNumber=e.buildNumber}if(e.buildUrl!==undefined){this.ctrfEnvironment.buildUrl=e.buildUrl}if(e.repositoryName!==undefined){this.ctrfEnvironment.repositoryName=e.repositoryName}if(e.repositoryUrl!==undefined){this.ctrfEnvironment.repositoryUrl=e.repositoryUrl}if(e.branchName!==undefined){this.ctrfEnvironment.branchName=e.branchName}if(e.testEnvironment!==undefined){this.ctrfEnvironment.testEnvironment=e.testEnvironment}}hasEnvironmentDetails(e){return Object.keys(e).length>0}buildSuitePath(e,t){var r;const n=(r=e.testFilePath.split("/").pop())!==null&&r!==void 0?r:"";const i=[n,...t.ancestorTitles];return i.join(" > ")}writeReportToFile(e){var t;const r=i.join((t=this.reporterConfigOptions.outputDir)!==null&&t!==void 0?t:this.defaultOutputDir,this.filename);const o=JSON.stringify(e,null,2);try{n.writeFileSync(r,o+"\n");console.log(`${this.reporterName}: successfully written ctrf json to %s/%s`,this.reporterConfigOptions.outputDir,this.filename)}catch(e){console.error(`Error writing ctrf json report:, ${String(e)}`)}}}t["default"]=GenerateCtrfReport},764:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var n=r(580);Object.defineProperty(t,"default",{enumerable:true,get:function(){return n.default}})},406:(e,t)=>{Object.defineProperty(t,"__esModule",{value:true});t.detectCIContext=detectCIContext;function removePrefix(e,t){if(!e){return undefined}return e.startsWith(t)?e.slice(t.length):e}function readEnvironment(){const e=globalThis;return e.process?.env??{}}function buildGithubRepositoryUrl(e){if(!e.GITHUB_SERVER_URL||!e.GITHUB_REPOSITORY){return undefined}return`${e.GITHUB_SERVER_URL}/${e.GITHUB_REPOSITORY}`}function buildGithubBuildUrl(e){if(!e.GITHUB_SERVER_URL||!e.GITHUB_REPOSITORY||!e.GITHUB_RUN_ID){return undefined}return`${e.GITHUB_SERVER_URL}/${e.GITHUB_REPOSITORY}/actions/runs/${e.GITHUB_RUN_ID}`}function detectGitHubBranch(e){if(e.GITHUB_HEAD_REF){return e.GITHUB_HEAD_REF}if(e.GITHUB_REF?.startsWith("refs/heads/")){return e.GITHUB_REF_NAME??removePrefix(e.GITHUB_REF,"refs/heads/")}return undefined}function detectGitHubActionsContext(e){return{branch:detectGitHubBranch(e),commitSha:e.GITHUB_SHA,repositoryUrl:buildGithubRepositoryUrl(e),buildNumber:e.GITHUB_RUN_NUMBER,buildUrl:buildGithubBuildUrl(e)}}function detectGitLabContext(e){return{branch:e.CI_COMMIT_BRANCH||e.CI_MERGE_REQUEST_SOURCE_BRANCH_NAME,commitSha:e.CI_COMMIT_SHA,repositoryUrl:e.CI_PROJECT_URL,buildNumber:e.CI_PIPELINE_IID,buildUrl:e.CI_PIPELINE_URL}}function detectAzurePipelinesContext(e){return{branch:removePrefix(e.BUILD_SOURCEBRANCH,"refs/heads/"),commitSha:e.BUILD_SOURCEVERSION,repositoryUrl:e.BUILD_REPOSITORY_URI,buildNumber:e.BUILD_BUILDNUMBER,buildUrl:e.SYSTEM_TEAMFOUNDATIONCOLLECTIONURI&&e.SYSTEM_TEAMPROJECT&&e.BUILD_BUILDID?`${e.SYSTEM_TEAMFOUNDATIONCOLLECTIONURI}${e.SYSTEM_TEAMPROJECT}/_build/results?buildId=${e.BUILD_BUILDID}`:undefined}}function detectCircleCIContext(e){return{branch:e.CIRCLE_BRANCH,commitSha:e.CIRCLE_SHA1,repositoryUrl:e.CIRCLE_REPOSITORY_URL,buildNumber:e.CIRCLE_BUILD_NUM,buildUrl:e.CIRCLE_BUILD_URL}}function detectJenkinsContext(e){return{branch:removePrefix(e.GIT_BRANCH,"origin/"),commitSha:e.GIT_COMMIT,repositoryUrl:e.GIT_URL,buildNumber:e.BUILD_NUMBER,buildUrl:e.BUILD_URL}}function detectBitbucketContext(e){return{branch:e.BITBUCKET_BRANCH,commitSha:e.BITBUCKET_COMMIT,repositoryUrl:e.BITBUCKET_GIT_HTTP_ORIGIN,buildNumber:e.BITBUCKET_BUILD_NUMBER,buildUrl:e.BITBUCKET_REPO_FULL_NAME&&e.BITBUCKET_BUILD_NUMBER?`https://bitbucket.org/${e.BITBUCKET_REPO_FULL_NAME}/pipelines/results/${e.BITBUCKET_BUILD_NUMBER}`:undefined}}const r=[{isMatch:e=>e.GITHUB_ACTIONS==="true",detect:detectGitHubActionsContext},{isMatch:e=>e.GITLAB_CI==="true",detect:detectGitLabContext},{isMatch:e=>e.TF_BUILD==="True",detect:detectAzurePipelinesContext},{isMatch:e=>e.CIRCLECI==="true",detect:detectCircleCIContext},{isMatch:e=>Boolean(e.JENKINS_URL),detect:detectJenkinsContext},{isMatch:e=>Boolean(e.BITBUCKET_BUILD_NUMBER),detect:detectBitbucketContext}];function detectCIContext(){const e=readEnvironment();for(const t of r){if(t.isMatch(e)){return t.detect(e)}}return{}}},827:(e,t)=>{Object.defineProperty(t,"__esModule",{value:true})},322:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;var i=Object.getOwnPropertyDescriptor(t,r);if(!i||("get"in i?!t.__esModule:i.writable||i.configurable)){i={enumerable:true,get:function(){return t[r]}}}Object.defineProperty(e,n,i)}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var i=this&&this.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))n(t,e,r)};Object.defineProperty(t,"__esModule",{value:true});t.createTestLocationCollector=t.enrichReportWithJsTestNameSourceSnippets=t.resolveSourceSnippetOptions=t.enrichReportWithSourceSnippets=t.ensureReportId=t.mapAttachmentsToTestResults=t.uploadArtifacts=t.uploadTestRun=t.detectCIContext=void 0;i(r(827),t);var o=r(406);Object.defineProperty(t,"detectCIContext",{enumerable:true,get:function(){return o.detectCIContext}});var s=r(969);Object.defineProperty(t,"uploadTestRun",{enumerable:true,get:function(){return s.uploadTestRun}});Object.defineProperty(t,"uploadArtifacts",{enumerable:true,get:function(){return s.uploadArtifacts}});Object.defineProperty(t,"mapAttachmentsToTestResults",{enumerable:true,get:function(){return s.mapAttachmentsToTestResults}});Object.defineProperty(t,"ensureReportId",{enumerable:true,get:function(){return s.ensureReportId}});var a=r(304);Object.defineProperty(t,"enrichReportWithSourceSnippets",{enumerable:true,get:function(){return a.enrichReportWithSourceSnippets}});Object.defineProperty(t,"resolveSourceSnippetOptions",{enumerable:true,get:function(){return a.resolveSourceSnippetOptions}});var u=r(913);Object.defineProperty(t,"enrichReportWithJsTestNameSourceSnippets",{enumerable:true,get:function(){return u.enrichReportWithJsTestNameSourceSnippets}});var l=r(293);Object.defineProperty(t,"createTestLocationCollector",{enumerable:true,get:function(){return l.createTestLocationCollector}})},913:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});t.enrichReportWithJsTestNameSourceSnippets=enrichReportWithJsTestNameSourceSnippets;const i=r(455);const o=n(r(760));const s=r(304);const a=3;const u=/\b(describe|it|test)(?:\.(only|skip))?\s*\(\s*(['"`])/g;async function enrichReportWithJsTestNameSourceSnippets(e,t){const r=(0,s.resolveSourceSnippetOptions)(t);const n=new Map;await Promise.all(e.results.tests.map((async e=>{if(e.snippet||!e.filePath){return}const t=o.default.resolve(r.sourceRoot,e.filePath);if(!isInsideSourceRoot(t,r.sourceRoot)){return}const i=await getCachedJsTestCandidates(t,n);if(!i){return}const s=rankCandidatesForTest(e,i).slice(0,a);if(s.length===0){return}e.line??(e.line=s[0].line);e.snippet=formatCandidateSnippet(s,r)})))}function getCachedJsTestCandidates(e,t){let r=t.get(e);if(!r){r=(0,i.readFile)(e,"utf-8").then((e=>scanJsTestCandidates(e))).catch((()=>undefined));t.set(e,r)}return r}function scanJsTestCandidates(e){const t=buildLineOffsets(e);const r=scanJsTestBlocks(e,t);const n=r.filter((e=>e.kind==="describe"));return r.filter((e=>e.kind==="test")).map((e=>{const t=n.filter((t=>t.startIndex<e.startIndex&&t.endIndex>=e.endIndex)).sort(((e,t)=>e.startIndex-t.startIndex)).map((e=>e.title));return{title:e.title,describeTitles:t,fullName:[...t,e.title].join(" ").trim(),line:e.startLine,snippet:e.snippet}}))}function scanJsTestBlocks(e,t){const r=[];u.lastIndex=0;let n;while((n=u.exec(e))!==null){if(isCommentedLine(e,n.index)){continue}const i=readQuotedTitle(e,n.index+n[0].length,n[3]);if(!i){continue}const o=skipWhitespaceAndFindComma(e,i.endIndex+1);if(o==null){continue}const s=n[1]==="describe"?"describe":"test";const a=n.index;const u=findCallbackOpenBrace(e,o+1);if(u==null){continue}const l=findMatchingBrace(e,u);if(l==null){continue}const c=findSnippetEndIndex(e,l);const d=e.slice(a,c).trim();if(!d){continue}r.push({kind:s,title:i.value.trim(),startIndex:a,endIndex:c,startLine:getLineNumber(t,a),snippet:d})}return r}function rankCandidatesForTest(e,t){const r=normalizeWhitespace(e.name);const n=normalizeDescribeChain(e.suite);const i=t.filter((e=>normalizeWhitespace(e.fullName)===r));if(i.length>0){return i}if(n){const e=t.filter((e=>normalizeWhitespace(e.title)===r&&normalizeWhitespace(e.describeTitles.join(" "))===n));if(e.length>0){return e}}const o=t.filter((e=>normalizeWhitespace(e.title)===r));if(o.length>0){return o}return t.filter((e=>{const t=normalizeWhitespace(e.title);if(!r.endsWith(t)){return false}const n=r.slice(0,r.length-t.length).trim();return n.length>0&&normalizeWhitespace(e.describeTitles.join(" "))===n}))}function formatCandidateSnippet(e,t){const r=e.length===1?e[0].snippet:e.map(((e,t)=>`Candidate ${t+1} (line ${e.line})\n${e.snippet}`)).join("\n\n");const n=r.split(/\r?\n/).slice(0,t.maxLines).join("\n").trim();if(n.length<=t.maxChars){return n}return n.slice(0,t.maxChars)}function findCallbackOpenBrace(e,t){for(let r=t;r<e.length;r++){const t=e[r];if(t==="'"||t==='"'||t==="`"){r=skipQuotedString(e,r);continue}if(t==="/"&&e[r+1]==="/"){r=skipLineComment(e,r+2);continue}if(t==="/"&&e[r+1]==="*"){r=skipBlockComment(e,r+2);continue}if(e.startsWith("=>",r)){return findNextBlockBrace(e,r+2)}if(startsWithWord(e,r,"function")){return findNextBlockBrace(e,r+"function".length)}if(t===";"){return undefined}}return undefined}function findNextBlockBrace(e,t){for(let r=t;r<e.length;r++){const t=e[r];if(t==="'"||t==='"'||t==="`"){r=skipQuotedString(e,r);continue}if(t==="{"){return r}if(t==="\n"&&looksLikeLineTerminator(e,r+1)){return undefined}}return undefined}function findMatchingBrace(e,t){let r=0;for(let n=t;n<e.length;n++){const t=e[n];if(t==="'"||t==='"'||t==="`"){n=skipQuotedString(e,n);continue}if(t==="/"&&e[n+1]==="/"){n=skipLineComment(e,n+2);continue}if(t==="/"&&e[n+1]==="*"){n=skipBlockComment(e,n+2);continue}if(t==="{"){r++;continue}if(t==="}"){r--;if(r===0){return n}}}return undefined}function readQuotedTitle(e,t,r){let n="";for(let i=t;i<e.length;i++){const t=e[i];if(t==="\\"){n+=t;if(i+1<e.length){i++;n+=e[i]}continue}if(t===r){return{value:n,endIndex:i}}if(t==="\n"&&r!=="`"){return undefined}n+=t}return undefined}function skipWhitespaceAndFindComma(e,t){for(let r=t;r<e.length;r++){const t=e[r];if(/\s/.test(t)){continue}return t===","?r:undefined}return undefined}function findSnippetEndIndex(e,t){let r=t+1;while(r<e.length){const t=e[r];if(t==="\r"||t==="\n"){return r}r++}return e.length}function skipQuotedString(e,t){const r=e[t];for(let n=t+1;n<e.length;n++){const t=e[n];if(t==="\\"){n++;continue}if(t===r){return n}}return e.length-1}function skipLineComment(e,t){for(let r=t;r<e.length;r++){if(e[r]==="\n"){return r}}return e.length-1}function skipBlockComment(e,t){for(let r=t;r<e.length-1;r++){if(e[r]==="*"&&e[r+1]==="/"){return r+1}}return e.length-1}function looksLikeLineTerminator(e,t){for(let r=t;r<e.length;r++){const t=e[r];if(!/\s/.test(t)){return t!=="."&&t!=="("}}return false}function buildLineOffsets(e){const t=[0];for(let r=0;r<e.length;r++){if(e[r]==="\n"){t.push(r+1)}}return t}function getLineNumber(e,t){let r=0;for(let n=0;n<e.length;n++){if(e[n]>t){break}r=n}return r+1}function isCommentedLine(e,t){const r=e.lastIndexOf("\n",t-1)+1;const n=e.slice(r,t).trimStart();return n.startsWith("//")||n.startsWith("*")}function startsWithWord(e,t,r){if(!e.startsWith(r,t)){return false}const n=t===0?"":e[t-1];const i=e[t+r.length]??"";return!isIdentifierChar(n)&&!isIdentifierChar(i)}function isIdentifierChar(e){return/[A-Za-z0-9_$]/.test(e)}function normalizeWhitespace(e){return(e??"").trim().replace(/\s+/g," ")}function normalizeDescribeChain(e){if(!e){return""}const t=e.split(">").map((e=>e.trim())).filter(Boolean);if(t.length===0){return""}const r=t[0].includes(".");const n=r?t.slice(1):t;return normalizeWhitespace(n.join(" "))}function isInsideSourceRoot(e,t){const r=o.default.relative(t,e);return r.length>0&&!r.startsWith("..")&&!o.default.isAbsolute(r)}},304:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});t.resolveSourceSnippetOptions=resolveSourceSnippetOptions;t.enrichReportWithSourceSnippets=enrichReportWithSourceSnippets;const i=r(455);const o=n(r(760));const s=2e3;const a=40;function resolveSourceSnippetOptions(e){return{sourceRoot:o.default.resolve(e?.sourceRoot??process.cwd()),maxChars:normalizePositiveInt(e?.maxChars,s),maxLines:normalizePositiveInt(e?.maxLines,a)}}async function enrichReportWithSourceSnippets(e,t){const r=resolveSourceSnippetOptions(t);const n=new Map;await Promise.all(e.results.tests.map((async e=>{if(e.snippet||!e.filePath||!e.line){return}const t=await tryExtractSnippet(e,r,n);if(t){e.snippet=t}})))}async function tryExtractSnippet(e,t,r){const n=o.default.resolve(t.sourceRoot,e.filePath);if(!isInsideSourceRoot(n,t.sourceRoot)){return undefined}const i=await getCachedFileContent(n,r);if(!i){return undefined}return extractEnclosingTestBlock(i,e.line,t)}function getCachedFileContent(e,t){let r=t.get(e);if(!r){r=(0,i.readFile)(e,"utf-8").catch((()=>undefined));t.set(e,r)}return r}function extractEnclosingTestBlock(e,t,r){const n=e.split(/\r?\n/);const i=Math.max(0,Math.min(n.length-1,t-1));const o=findTestStart(n,i);if(o==null){return undefined}const s=[];let a=0;let u=false;for(let e=o;e<n.length&&s.length<r.maxLines;e++){const t=n[e];s.push(t);for(const e of t){if(e==="{"){a++;u=true}else if(e==="}"){a--}}if(u&&a<=0&&isJsTestBlockTerminator(t)){break}}const l=s.join("\n").trim();if(!l){return undefined}return l.length<=r.maxChars?l:l.slice(0,r.maxChars)}function findTestStart(e,t){for(let r=t;r>=0;r--){if(/\b(?:test|it)(?:\.(?:only|skip|fixme|slow))?\s*\(/.test(e[r])){return r}}return undefined}function isJsTestBlockTerminator(e){let t=e.length-1;while(t>=0&&/\s/.test(e[t])){t--}if(t>=0&&e[t]===";"){t--}while(t>=0&&/\s/.test(e[t])){t--}if(t<1||e[t]!==")"){return false}t--;while(t>=0&&/\s/.test(e[t])){t--}return t>=0&&e[t]==="}"}function isInsideSourceRoot(e,t){const r=o.default.relative(t,e);return r.length>0&&!r.startsWith("..")&&!o.default.isAbsolute(r)}function normalizePositiveInt(e,t){return typeof e==="number"&&Number.isInteger(e)&&e>0?e:t}},293:(e,t)=>{Object.defineProperty(t,"__esModule",{value:true});t.createTestLocationCollector=createTestLocationCollector;function createTestLocationCollector(){const e=new Map;return{add(t,r){if(!t||!isValidLocation(r)){return}const n=e.get(t)??[];n.push(r);e.set(t,n)},applyToReport(t){const r=new Map([...e.entries()].map((([e,t])=>[e,[...t]])));for(const e of t.results.tests){const t=r.get(e.name);const n=t?.shift();if(!n){continue}e.filePath??(e.filePath=n.filePath);e.line??(e.line=n.line)}}}}function isValidLocation(e){return Boolean(e.filePath)&&Number.isInteger(e.line)&&e.line>0}},969:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t.ensureReportId=ensureReportId;t.uploadTestRun=uploadTestRun;t.mapAttachmentsToTestResults=mapAttachmentsToTestResults;t.uploadArtifacts=uploadArtifacts;const n=r(406);const i=r(304);const o="https://api.testream.app";function ensureReportId(e){if(typeof e.reportId==="string"&&e.reportId.trim().length>0){return e.reportId}const t=crypto.randomUUID();e.reportId=t;return t}function resolveApiUrl(e){const t=normalizeApiUrl(e);if(t){return t}const r=getEnvApiUrl();if(r){return r}return o}function getEnvApiUrl(){if(typeof process==="undefined"||!process?.env){return undefined}return normalizeApiUrl(process.env.TESTREAM_API_URL)}function normalizeApiUrl(e){if(!e){return undefined}const t=e.trim();if(!t){return undefined}let r=t;while(r.endsWith("/")){r=r.slice(0,-1)}return r}function isReportAlreadyExistsConflict(e){return e.errorCode==="report_already_exists"}function formatUploadError(e){const t=e.detail||e.title||e.rawBody||"Unknown error";const r=e.errorCode?`, code=${e.errorCode}`:"";return`Upload failed (HTTP ${e.statusCode}${r}): ${t}`}async function parseHttpError(e){const t=await e.text();const r=e.headers.get("content-type")||"";if(r.toLowerCase().includes("json")&&t.trim().length>0){try{const r=JSON.parse(t);return{statusCode:e.status,title:r.title,detail:r.detail||r.details||r.error,errorCode:r.errorCode,rawBody:t}}catch{}}return{statusCode:e.status,rawBody:t}}function resolveUploadContext(e){const t=(0,n.detectCIContext)();return{commitSha:e.commitSha??t.commitSha,branch:e.branch??t.branch,repositoryUrl:e.repositoryUrl??t.repositoryUrl,buildName:e.buildName,buildNumber:e.buildNumber??t.buildNumber,buildUrl:e.buildUrl??t.buildUrl,testEnvironment:e.testEnvironment,appName:e.appName,appVersion:e.appVersion,testType:e.testType}}async function uploadTestRun(e){const{report:t,apiKey:r}=e;const n=resolveApiUrl(e.apiUrl);const o=ensureReportId(t);const s=resolveUploadContext(e);await(0,i.enrichReportWithSourceSnippets)(t);const a={report:t,reportId:o,...s};console.log("Uploading test results...");let u;try{u=await fetch(`${n}/api/v1/ingest`,{method:"POST",headers:{"X-API-KEY":r,"Content-Type":"application/json"},body:JSON.stringify(a)})}catch(e){const t=e instanceof Error?e.message:String(e);const r=`Connection failed: ${t}`;console.error(r);return{success:false,reportId:o,error:r}}if(!u.ok){const e=await parseHttpError(u);if(u.status===409&&isReportAlreadyExistsConflict(e)){console.warn("Report already exists (workflow may have been re-run)");return{success:true,reportId:o,summary:{passed:t.results.summary.passed,failed:t.results.summary.failed,skipped:t.results.summary.skipped,total:t.results.summary.tests},alreadyExists:true,statusCode:e.statusCode,errorCode:e.errorCode}}const r=formatUploadError(e);console.error(r);return{success:false,reportId:o,error:r,statusCode:e.statusCode,errorCode:e.errorCode,errorDetail:e.detail||e.rawBody}}const l=await u.json();console.log(`✓ Test results uploaded successfully`);console.log(` Report ID: ${l.reportId}`);console.log(` Test Run ID: ${l.testRunId}`);console.log(` Tests: ${l.summary.passed}/${l.summary.total} passed`);return{success:true,reportId:l.reportId,testRunId:l.testRunId,summary:{passed:l.summary.passed,failed:l.summary.failed,skipped:l.summary.skipped,total:l.summary.total},testResults:l.testResults}}function mapAttachmentsToTestResults(e,t){const r=new Map;for(const e of t){const t=r.get(e.name)??[];t.push(e.id);r.set(e.name,t)}const n=[];for(const t of e){const e=r.get(t.name);const i=e?.shift();if(!t.attachments||t.attachments.length===0){continue}if(!i){console.warn(`Skipping artifact upload: could not match test result for "${t.name}"`);continue}n.push({testResultId:i,attachments:t.attachments})}return n}async function uploadArtifacts(e){const{reportId:t,apiKey:r,testResults:n}=e;const i=resolveApiUrl(e.apiUrl);let o=0;for(const e of n){for(const n of e.attachments){try{const s=await uploadSingleArtifact({testResultId:e.testResultId,attachment:n,reportId:t,apiKey:r,apiUrl:i});if(s)o++}catch(e){const t=e instanceof Error?e.message:String(e);console.error(`Failed to upload artifact ${n.name}: ${t}`)}}}if(o>0){console.log(`✓ Uploaded ${o} artifact(s)`)}return o}async function uploadSingleArtifact(e){const{testResultId:t,attachment:n,reportId:i,apiKey:o,apiUrl:s}=e;const a=await Promise.resolve().then(r.t.bind(r,455,23));const u=await Promise.resolve().then(r.t.bind(r,760,23));const l=u.resolve(n.path);try{await a.access(l)}catch{console.warn(`Artifact not found: ${u.basename(l)}`);return false}let c;let d;const f=u.basename(l);const p=n.contentType||"application/octet-stream";try{c=await a.readFile(l);d=c.byteLength}catch(e){const t=e instanceof Error?e.message:String(e);throw new Error(`Failed to read file: ${t}`)}try{return await uploadWithPresignedUrl({testResultId:t,reportId:i,apiKey:o,apiUrl:s,attachmentName:n.name,fileName:f,contentType:p,sizeBytes:d,fileBuffer:c})}catch(e){if(!(e instanceof LegacyUploadRequiredError)){throw e}return await uploadWithLegacyEndpoint({testResultId:t,attachmentName:n.name,reportId:i,apiKey:o,apiUrl:s,fileName:f,contentType:p,fileBuffer:c})}}class LegacyUploadRequiredError extends Error{constructor(){super("Legacy upload endpoint required")}}async function uploadWithPresignedUrl(e){const{testResultId:t,reportId:r,apiKey:n,apiUrl:i,attachmentName:o,fileName:s,contentType:a,sizeBytes:u,fileBuffer:l}=e;const c={testResultId:t,ctrfAttachmentName:o,fileName:s,contentType:a,sizeBytes:u};const d=await fetch(`${i}/api/v1/artifacts/${r}/upload-url`,{method:"POST",headers:{"X-API-KEY":n,"Content-Type":"application/json"},body:JSON.stringify(c)});if(shouldFallbackToLegacyUpload(d.status)){throw new LegacyUploadRequiredError}if(!d.ok){const e=await d.text();throw new Error(`Failed to create direct upload URL (HTTP ${d.status}): ${e}`)}const f=await d.json();const p={...f.requiredHeaders};if(!hasHeaderIgnoreCase(p,"Content-Type")){p["Content-Type"]=a}const h=await fetch(f.uploadUrl,{method:"PUT",headers:p,body:l});if(!h.ok){const e=await h.text();throw new Error(`Direct artifact upload failed (HTTP ${h.status}): ${e}`)}const m={testResultId:t,ctrfAttachmentName:o,fileName:s,contentType:a,sizeBytes:u,storageKey:f.storageKey};const b=await fetch(`${i}/api/v1/artifacts/${r}/complete`,{method:"POST",headers:{"X-API-KEY":n,"Content-Type":"application/json"},body:JSON.stringify(m)});if(!b.ok){const e=await b.text();throw new Error(`Failed to finalize artifact upload (HTTP ${b.status}): ${e}`)}return true}async function uploadWithLegacyEndpoint(e){const{testResultId:t,attachmentName:r,reportId:n,apiKey:i,apiUrl:o,fileName:s,contentType:a,fileBuffer:u}=e;const l=new Blob([new Uint8Array(u)],{type:a});const c=new FormData;c.append("testResultId",t);c.append("ctrfAttachmentName",r);c.append("file",l,s);const d=await fetch(`${o}/api/v1/artifacts/${n}`,{method:"POST",headers:{"X-API-KEY":i},body:c});if(!d.ok){const e=await d.text();throw new Error(`Legacy artifact upload failed (HTTP ${d.status}): ${e}`)}return true}function shouldFallbackToLegacyUpload(e){return e===404||e===405||e===501}function hasHeaderIgnoreCase(e,t){const r=t.toLowerCase();return Object.keys(e).some((e=>e.toLowerCase()===r))}},665:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;var i=Object.getOwnPropertyDescriptor(t,r);if(!i||("get"in i?!t.__esModule:i.writable||i.configurable)){i={enumerable:true,get:function(){return t[r]}}}Object.defineProperty(e,n,i)}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var o=this&&this.__importStar||function(){var ownKeys=function(e){ownKeys=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r))t[t.length]=r;return t};return ownKeys(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=ownKeys(e),o=0;o<r.length;o++)if(r[o]!=="default")n(t,e,r[o]);i(t,e);return t}}();var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});t.TestreamJestReporter=void 0;const a=s(r(764));const u=o(r(943));const l=o(r(928));const c=r(13);const d=r(148);const f=r(10);class TestreamJestReporter{constructor(e,t,r={}){this.outputDir="ctrf";this.outputFile="ctrf-report.json";this.testLocations=(0,c.createJestTestLocationCollector)();this.missingLocationWarningShown=false;this.config={uploadEnabled:true,failOnUploadError:false,apiKey:"",...t};const n={outputDir:this.outputDir,outputFile:this.outputFile};if(this.config.testEnvironment)n.testEnvironment=this.config.testEnvironment;if(this.config.appName)n.appName=this.config.appName;if(this.config.appVersion)n.appVersion=this.config.appVersion;if(this.config.buildName)n.buildName=this.config.buildName;if(this.config.buildNumber)n.buildNumber=this.config.buildNumber;if(this.config.buildUrl)n.buildUrl=this.config.buildUrl;if(this.config.testType)n.testType=this.config.testType;if(this.config.branch)n.branchName=this.config.branch;if(this.config.commitSha)n.commit=this.config.commitSha;this.ctrfReporter=new a.default(e,n,r)}onRunStart(e,t){if(this.ctrfReporter.onRunStart){return this.ctrfReporter.onRunStart()}}onTestStart(e){if(this.ctrfReporter.onTestStart){return this.ctrfReporter.onTestStart()}}onTestResult(e,t,r){this.warnIfLocationsUnavailable(t);(0,c.addJestTestLocationsToCollector)(this.testLocations,t);if(this.ctrfReporter.onTestResult){return this.ctrfReporter.onTestResult(e,t)}}async onRunComplete(e,t){if(this.ctrfReporter.onRunComplete){this.ctrfReporter.onRunComplete()}const r=await this.readCTRFReport();if(!r){console.error("Failed to read CTRF report, skipping upload");return}await(0,c.enrichJestCtrfReport)(r,this.testLocations);await(0,d.enrichReportWithJestSourceSnippets)(r);await this.writeCTRFReport(r);console.info(`CTRF report written to: ${l.join(this.outputDir,this.outputFile)}`);if(this.config.uploadEnabled&&this.config.apiKey){await this.uploadReport(r)}}async readCTRFReport(){const e=l.join(this.outputDir,this.outputFile);try{const t=await u.readFile(e,"utf-8");const r=JSON.parse(t);r.results.tool.name="jest";r.generatedBy="@testream/jest-reporter";return r}catch(t){console.error(`Failed to read CTRF report from ${e}: ${t instanceof Error?t.message:String(t)}`);return null}}async writeCTRFReport(e){const t=l.join(this.outputDir,this.outputFile);await u.writeFile(t,JSON.stringify(e,null,2))}warnIfLocationsUnavailable(e){if(this.missingLocationWarningShown){return}const t=e.testResults.some((e=>e.location?.line!=null));if(t){return}this.missingLocationWarningShown=true;console.warn("[testream/jest-reporter] Jest test locations are unavailable. The reporter will still attempt source snippet inference, but setting testLocationInResults: true in your Jest config gives more reliable line metadata.")}async uploadReport(e){const t=await(0,f.uploadToApi)({report:e,apiKey:this.config.apiKey,branch:this.config.branch,commitSha:this.config.commitSha,repositoryUrl:this.config.repositoryUrl,buildName:this.config.buildName,buildNumber:this.config.buildNumber,buildUrl:this.config.buildUrl,testEnvironment:this.config.testEnvironment,appName:this.config.appName,appVersion:this.config.appVersion,testType:this.config.testType});if(!t.success&&this.config.failOnUploadError){throw new Error(`Upload failed: ${t.error}`)}}}t.TestreamJestReporter=TestreamJestReporter;t["default"]=TestreamJestReporter},148:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t.enrichReportWithJestSourceSnippets=enrichReportWithJestSourceSnippets;const n=r(322);async function enrichReportWithJestSourceSnippets(e,t){await(0,n.enrichReportWithJsTestNameSourceSnippets)(e,t)}},13:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t.addJestTestLocationsToCollector=addJestTestLocationsToCollector;t.enrichJestCtrfReport=enrichJestCtrfReport;t.createJestTestLocationCollector=createJestTestLocationCollector;const n=r(322);function addJestTestLocationsToCollector(e,t){for(const r of t.testResults){if(!r.fullName||!r.location?.line){continue}e.add(r.fullName,{filePath:t.testFilePath,line:r.location.line})}}async function enrichJestCtrfReport(e,t){t.applyToReport(e);await(0,n.enrichReportWithSourceSnippets)(e)}function createJestTestLocationCollector(){return(0,n.createTestLocationCollector)()}},10:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:true});t.detectGitContext=void 0;t.uploadToApi=uploadToApi;const n=r(322);async function uploadToApi(e){return(0,n.uploadTestRun)({report:e.report,apiKey:e.apiKey,apiUrl:e.apiUrl,commitSha:e.commitSha,branch:e.branch,repositoryUrl:e.repositoryUrl,buildName:e.buildName,buildNumber:e.buildNumber,buildUrl:e.buildUrl,testEnvironment:e.testEnvironment,appName:e.appName,appVersion:e.appVersion,testType:e.testType})}t.detectGitContext=n.detectCIContext},896:e=>{e.exports=require("fs")},943:e=>{e.exports=require("fs/promises")},455:e=>{e.exports=require("node:fs/promises")},760:e=>{e.exports=require("node:path")},928:e=>{e.exports=require("path")}};var t={};function __nccwpck_require__(r){var n=t[r];if(n!==undefined){return n.exports}var i=t[r]={exports:{}};var o=true;try{e[r].call(i.exports,i,i.exports,__nccwpck_require__);o=false}finally{if(o)delete t[r]}return i.exports}(()=>{var e=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__;var t;__nccwpck_require__.t=function(r,n){if(n&1)r=this(r);if(n&8)return r;if(typeof r==="object"&&r){if(n&4&&r.__esModule)return r;if(n&16&&typeof r.then==="function")return r}var i=Object.create(null);__nccwpck_require__.r(i);var o={};t=t||[null,e({}),e([]),e(e)];for(var s=n&2&&r;typeof s=="object"&&!~t.indexOf(s);s=e(s)){Object.getOwnPropertyNames(s).forEach((e=>o[e]=()=>r[e]))}o["default"]=()=>r;__nccwpck_require__.d(i,o);return i}})();(()=>{__nccwpck_require__.d=(e,t)=>{for(var r in t){if(__nccwpck_require__.o(t,r)&&!__nccwpck_require__.o(e,r)){Object.defineProperty(e,r,{enumerable:true,get:t[r]})}}}})();(()=>{__nccwpck_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})();(()=>{__nccwpck_require__.r=e=>{if(typeof Symbol!=="undefined"&&Symbol.toStringTag){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}Object.defineProperty(e,"__esModule",{value:true})}})();if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var r={};(()=>{var e=r;Object.defineProperty(e,"__esModule",{value:true});e.TestreamJestReporter=e["default"]=void 0;var t=__nccwpck_require__(665);Object.defineProperty(e,"default",{enumerable:true,get:function(){return t.TestreamJestReporter}});var n=__nccwpck_require__(665);Object.defineProperty(e,"TestreamJestReporter",{enumerable:true,get:function(){return n.TestreamJestReporter}})})();module.exports=r})();
@@ -10,6 +10,8 @@ export declare class TestreamJestReporter implements Reporter {
10
10
  private readonly ctrfReporter;
11
11
  private readonly outputDir;
12
12
  private readonly outputFile;
13
+ private readonly testLocations;
14
+ private missingLocationWarningShown;
13
15
  constructor(globalConfig: unknown, options?: JestReporterConfig, context?: unknown);
14
16
  /**
15
17
  * Called when test run starts
@@ -31,6 +33,8 @@ export declare class TestreamJestReporter implements Reporter {
31
33
  * Read CTRF report from file
32
34
  */
33
35
  private readCTRFReport;
36
+ private writeCTRFReport;
37
+ private warnIfLocationsUnavailable;
34
38
  /**
35
39
  * Upload report to Testream API
36
40
  */
@@ -0,0 +1,2 @@
1
+ import { type CTRFReport, type SourceSnippetOptions } from '@jira-test-manager/shared-types';
2
+ export declare function enrichReportWithJestSourceSnippets(report: CTRFReport, options?: SourceSnippetOptions): Promise<void>;
@@ -0,0 +1,15 @@
1
+ import { type CTRFReport, type TestLocationCollector } from '@jira-test-manager/shared-types';
2
+ export interface JestAssertionLocationLike {
3
+ fullName: string;
4
+ location?: {
5
+ line: number;
6
+ column?: number;
7
+ } | null;
8
+ }
9
+ export interface JestTestResultLocationsLike {
10
+ testFilePath: string;
11
+ testResults: readonly JestAssertionLocationLike[];
12
+ }
13
+ export declare function addJestTestLocationsToCollector(collector: TestLocationCollector, testResult: JestTestResultLocationsLike): void;
14
+ export declare function enrichJestCtrfReport(report: CTRFReport, collector: TestLocationCollector): Promise<void>;
15
+ export declare function createJestTestLocationCollector(): TestLocationCollector;
package/package.json CHANGED
@@ -1,17 +1,18 @@
1
1
  {
2
2
  "name": "@testream/jest-reporter",
3
- "version": "1.1.0",
3
+ "version": "1.2.1",
4
4
  "description": "Jest plugin to upload test results to Testream",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "scripts": {
8
- "build": "npm run build:bundle && npm run build:types",
8
+ "clean": "rm -rf dist",
9
+ "build": "npm run clean && npm run build:bundle && npm run build:types",
9
10
  "build:bundle": "ncc build src/index.ts -o dist --minify",
10
11
  "build:types": "tsc --declaration --emitDeclarationOnly --outDir dist",
11
12
  "format": "prettier --write '**/*.ts'",
12
13
  "lint": "eslint src/**/*.ts",
13
14
  "prepublishOnly": "npm run build",
14
- "test": "echo \"No tests yet\" && exit 0",
15
+ "test": "vitest run",
15
16
  "all": "npm run format && npm run lint && npm run build"
16
17
  },
17
18
  "repository": {
@@ -38,9 +39,13 @@
38
39
  "@jest/reporters": ">=27.0.0",
39
40
  "@jest/test-result": ">=27.0.0"
40
41
  },
42
+ "overrides": {
43
+ "@babel/core": "^7.29.7",
44
+ "js-yaml": "^4.2.0"
45
+ },
41
46
  "devDependencies": {
42
- "@jest/reporters": "^29.0.0",
43
- "@jest/test-result": "^29.0.0",
47
+ "@jest/reporters": "^30.4.1",
48
+ "@jest/test-result": "^30.4.1",
44
49
  "@jira-test-manager/shared-types": "*",
45
50
  "@types/node": "^20.10.6",
46
51
  "@typescript-eslint/eslint-plugin": "^6.17.0",
@@ -48,7 +53,8 @@
48
53
  "@vercel/ncc": "^0.38.1",
49
54
  "eslint": "^8.56.0",
50
55
  "prettier": "^3.1.1",
51
- "typescript": "^5.3.3"
56
+ "typescript": "^5.3.3",
57
+ "vitest": "^4.1.9"
52
58
  },
53
59
  "engines": {
54
60
  "node": ">=18.0.0"