Skip to content

Conversation

zenibako
Copy link
Contributor

@zenibako zenibako commented Mar 27, 2025

What does this PR do?

  • Adds error handling to synchronous test runs.
  • Tidies up formatting of replacement error message.
  • Escapes when command meets valid condition of server-side error message.

What issues does this PR fix or reference?

forcedotcom/cli#3217
forcedotcom/salesforcedx-apex#306 (comment)
#706

@cristiand391
Copy link
Member

@zenibako thank you for the PR!
I should have caught this during qa 🤦🏼‍♂️

QA notes:

❌ still shows server error if no tests are specified

➜  dreamhouse-lwc git:(main) sf apex run test --synchronous -c
 ›   Warning: @salesforce/plugin-apex is a linked ESM module and cannot be auto-transpiled. Existing compiled source will be used instead.
testLevel: RunLocalTests
Error (INVALID_INPUT): Always provide a classes, suites, tests, or testLevel property.

I made it print the testLevel line, we calculate that value here:

const testLevel = await validateFlags(

API docs for test-level:

Permissible values include:
RunSpecifiedTests
...
RunLocalTests
...
RunAllTestsInOrg
...

https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/intro_rest_resources.htm

given we still get Always provide a classes, suites, tests, or testLevel property. with RunLocalTests, can you remove the flag checks from handleTestError?

@zenibako
Copy link
Contributor Author

@cristiand391 I fixed the flag logic and added some tests. How do those look?

@cristiand391 cristiand391 changed the base branch from main to cd/pr-710 April 3, 2025 17:02
@cristiand391 cristiand391 merged commit 48b337e into salesforcecli:cd/pr-710 Apr 3, 2025
1 check passed
@cristiand391
Copy link
Member

thank you @zenibako
I merged this into a new branch created by me to get tests running, will QA in a bit and merge to main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants