Skip to content

Commit 1624982

Browse files
Factor out BaseTestManager.getDiagnosticMessage().
1 parent 101e5ff commit 1624982

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

src/client/testing/common/managers/baseTestManager.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -493,22 +493,23 @@ export abstract class BaseTestManager implements ITestManager {
493493

494494
private createDiagnostics(message: ITestNonPassingMessage): Diagnostic {
495495
const stackStart = message.locationStack[0];
496-
const diagPrefix = this.unitTestDiagnosticService.getMessagePrefix(message.status);
496+
const diagMsg = this.getDiagnosticMessage(message);
497497
const severity = this.unitTestDiagnosticService.getSeverity(message.severity)!;
498-
const diagMsg = message.message ? message.message.split('\n')[0] : '';
499-
const diagnostic = new Diagnostic(
500-
stackStart.location.range,
501-
`${diagPrefix ? `${diagPrefix}: ` : 'Ok'}${diagMsg}`,
502-
severity,
503-
);
498+
const diagnostic = new Diagnostic(stackStart.location.range, diagMsg, severity);
504499
diagnostic.code = message.code;
505500
diagnostic.source = message.provider;
506501
const relatedInfoArr: DiagnosticRelatedInformation[] = [];
507-
for (const frameDetails of message.locationStack!) {
502+
for (const frameDetails of message.locationStack) {
508503
const relatedInfo = new DiagnosticRelatedInformation(frameDetails.location, frameDetails.lineText);
509504
relatedInfoArr.push(relatedInfo);
510505
}
511506
diagnostic.relatedInformation = relatedInfoArr;
512507
return diagnostic;
513508
}
509+
510+
private getDiagnosticMessage(message: ITestNonPassingMessage): string {
511+
const diagPrefix = this.unitTestDiagnosticService.getMessagePrefix(message.status);
512+
const diagMsg = message.message ? message.message.split('\n')[0] : '';
513+
return `${diagPrefix ? `${diagPrefix}: ` : 'Ok'}${diagMsg}`;
514+
}
514515
}

0 commit comments

Comments
 (0)