From a08d13584ce9486b423c7a02663a8998e678f28e Mon Sep 17 00:00:00 2001 From: azlam Date: Thu, 14 Sep 2023 17:30:58 +1000 Subject: [PATCH] fix(apextests): add error handling to replace This is probably an incorrect fix, will fix as more details emerge. Just return the original one in case replacement fails --- packages/core/src/apextest/TriggerApexTests.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/core/src/apextest/TriggerApexTests.ts b/packages/core/src/apextest/TriggerApexTests.ts index 60aa40642..7fcd0ae89 100644 --- a/packages/core/src/apextest/TriggerApexTests.ts +++ b/packages/core/src/apextest/TriggerApexTests.ts @@ -457,20 +457,31 @@ export default class TriggerApexTests { private fixBadNamespaceClassFullNames(testResult: any): any { let modifiedTestResult = _.cloneDeep(testResult); + try + { modifiedTestResult.tests = modifiedTestResult.tests.map((test) => { return { ...test, ...{ - fullName: test.fullName.replace('__', '.'), + fullName: test.fullName?.replace('__', '.'), apexClass: { ...test.apexClass, ...{ - fullName: test.apexClass.fullName.replace('__', '.'), + fullName: test.apexClass?.fullName?.replace('__', '.'), }, }, }, }; }); + }catch(error) + { + SFPLogger.log( + `Unable to fix bad namespace class full names due to ${error}`, + LoggerLevel.DEBUG, + this.fileLogger + ); + modifiedTestResult = _.cloneDeep(testResult); + } return modifiedTestResult; }