Skip to content

Commit e14ab5b

Browse files
fix: improve no tests in org error message, suggest actions W-17866064 (#706)
* fix: improve no tests in org error message, suggest actions * chore: only catch catch this error * chore: bump deps
1 parent c1e2e75 commit e14ab5b

File tree

3 files changed

+593
-192
lines changed

3 files changed

+593
-192
lines changed

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77
"dependencies": {
88
"@salesforce/apex-node": "^8.1.19",
99
"@salesforce/core": "^8.8.5",
10-
"@salesforce/kit": "^3.2.2",
11-
"@salesforce/sf-plugins-core": "^12",
10+
"@salesforce/kit": "^3.2.3",
11+
"@salesforce/sf-plugins-core": "^12.2.1",
1212
"ansis": "^3.3.1"
1313
},
1414
"devDependencies": {
15-
"@oclif/core": "^4.0.34",
16-
"@oclif/plugin-command-snapshot": "^5.2.23",
15+
"@oclif/core": "^4.2.10",
16+
"@oclif/plugin-command-snapshot": "^5.2.37",
1717
"@salesforce/cli-plugins-testkit": "^5.3.39",
1818
"@salesforce/dev-scripts": "^10.2.11",
19-
"@salesforce/plugin-command-reference": "^3.1.43",
19+
"@salesforce/plugin-command-reference": "^3.1.48",
2020
"eslint-plugin-sf-plugin": "^1.20.16",
21-
"oclif": "^4.17.30",
21+
"oclif": "^4.17.37",
2222
"ts-node": "^10.9.2",
2323
"typescript": "^5.7.3"
2424
},

src/commands/apex/run/test.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -201,15 +201,25 @@ export default class Test extends SfCommand<RunCommandResult> {
201201
skipCodeCoverage: !flags['code-coverage'],
202202
};
203203

204-
// cast as TestRunIdResult because we're building an async payload which will return an async result
205-
return (await testService.runTestAsynchronous(
206-
payload,
207-
flags['code-coverage'],
208-
flags.wait && flags.wait.minutes > 0 ? false : !(flags.synchronous && !this.jsonEnabled()),
209-
undefined,
210-
this.cancellationTokenSource.token,
211-
flags.wait
212-
)) as TestRunIdResult;
204+
try {
205+
// cast as TestRunIdResult because we're building an async payload which will return an async result
206+
return (await testService.runTestAsynchronous(
207+
payload,
208+
flags['code-coverage'],
209+
flags.wait && flags.wait.minutes > 0 ? false : !(flags.synchronous && !this.jsonEnabled()),
210+
undefined,
211+
this.cancellationTokenSource.token,
212+
flags.wait
213+
)) as TestRunIdResult;
214+
} catch (e) {
215+
const error = SfError.wrap(e);
216+
if (error.message.includes('Always provide a classes, suites, tests, or testLevel property')) {
217+
error.message = 'There are no apex tests to run in the org';
218+
error.actions = ['Ensure Apex Tests exist in the org'];
219+
}
220+
221+
throw error;
222+
}
213223
}
214224
}
215225

0 commit comments

Comments
 (0)