Skip to content

Commit

Permalink
fix(apextest): fix error message when apex test is cancelled in the org
Browse files Browse the repository at this point in the history
fix an incorrect error message which confuses users on what to be done
  • Loading branch information
azlam-abdulsalam committed Feb 29, 2024
1 parent 621114c commit 612ae62
Show file tree
Hide file tree
Showing 3 changed files with 11,944 additions and 16,268 deletions.
1 change: 1 addition & 0 deletions packages/sfp-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"chalk": "^4.1.2",
"cli-table": "0.3.11",
"datadog-metrics": "^0.9.3",
"dedent": "^1.5.1",
"dotenv": "16.3.1",
"fast-xml-parser": "4.2.7",
"fs-extra": "^11.1.1",
Expand Down
18 changes: 16 additions & 2 deletions packages/sfp-cli/src/core/apextest/TriggerApexTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { Duration } from '@salesforce/kit';
import ClearCodeCoverage from './ClearCodeCoverage';
import _ from 'lodash';
const retry = require('async-retry');
import dedent from 'dedent';

export default class TriggerApexTests {
private conn: Connection;
Expand Down Expand Up @@ -102,6 +103,16 @@ export default class TriggerApexTests {
suites
)) as TestResult;
} catch (error) {
if(error.message.includes(`Cannot read properties of undefined (reading 'Status')`))
{
return {
result: false,
id: null,
message: dedent `Unable to obtain status of test run, Did you cancel the test run?
This error happens when the test run is cancelled and the status is not available.
Please retry`,
};
}
return {
result: false,
id: null,
Expand Down Expand Up @@ -149,7 +160,10 @@ export default class TriggerApexTests {
return {
result: false,
id: testResult.summary.testRunId,
message: 'Unable to fetch test execution results, Please retry',
message: dedent `Unable to fetch test execution results,
Please check the results in the org by using the URL below
https://${this.conn.instanceUrl}/lightning/setup/ApexTestHistory/home
Please try the test execution again`,
};
}

Expand Down Expand Up @@ -761,7 +775,7 @@ export class ProgressReporter implements Progress<ApexTestProgressValue> {
}
}
} catch (error) {
//Ignore any results during reporting
console.log(`Bummer`)
}
}
}
Loading

0 comments on commit 612ae62

Please sign in to comment.