Skip to content

Commit 4e3b601

Browse files
barbaralocsiAnWeber
authored andcommitted
fix: use different exit codes for errored and failed tests
1 parent f2663e5 commit 4e3b601

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

src/cli/send/plugin/testExitCodeInterceptor.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,30 @@ export const testExitCodeInterceptor = {
1212

1313
afterTrigger: async function bail(hookContext: HookTriggerContext<[models.ProcessorContext], boolean>) {
1414
const context = hookContext.args[0];
15-
const hasFailedOrErroredTestResult = context.httpRegion.testResults?.some?.(
16-
obj => obj.status === models.TestResultStatus.FAILED || obj.status === models.TestResultStatus.ERROR
17-
);
18-
if (hasFailedOrErroredTestResult) {
15+
16+
if (context.httpRegion.testResults === undefined) {
17+
return true;
18+
}
19+
20+
let hasErroredTestResult = false;
21+
let hasFailedTestResult = false;
22+
23+
for (const testResult of context.httpRegion.testResults) {
24+
if (testResult.status === models.TestResultStatus.ERROR) {
25+
hasErroredTestResult = true;
26+
break;
27+
}
28+
if (testResult.status === models.TestResultStatus.FAILED) {
29+
hasFailedTestResult = true;
30+
}
31+
}
32+
33+
if (hasErroredTestResult) {
34+
process.exitCode = 19;
35+
} else if (hasFailedTestResult) {
1936
process.exitCode = 20;
2037
}
38+
2139
return true;
2240
},
2341
};

0 commit comments

Comments
 (0)