From 57c3da965d83da7fedee254131ae46c4465aae72 Mon Sep 17 00:00:00 2001 From: Matt Carvin <90224411+mcarvin8@users.noreply.github.com> Date: Thu, 24 Sep 2026 11:05:20 -0400 Subject: [PATCH] fix: default validate test-level to RunSpecifiedTests when --tests set project deploy validate overrode the shared testLevelFlag default with a static RunLocalTests, so passing --tests without --test-level sent runTests with testLevel=RunLocalTests and the Metadata API rejected it: "INVALID_OPERATION: runTests can only be used with a testLevel of RunSpecifiedTests". Match project deploy start's behavior. Co-Authored-By: Claude Opus 5.5 --- messages/deploy.metadata.validate.md | 2 +- src/commands/project/deploy/validate.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/messages/deploy.metadata.validate.md b/messages/deploy.metadata.validate.md index 506ccfa7..ca3b54ce 100644 --- a/messages/deploy.metadata.validate.md +++ b/messages/deploy.metadata.validate.md @@ -48,7 +48,7 @@ Valid values are: - RunSpecifiedTests — Runs only the tests that you specify with the --tests flag. Code coverage requirements differ from the default coverage requirements when using this test level. Executed tests must comprise a minimum of 75% code coverage for each class and trigger in the deployment package. This coverage is computed for each class and trigger individually and is different than the overall coverage percentage. -- RunLocalTests — All tests in your org are run, except the ones that originate from installed managed and unlocked packages. This test level is the default. +- RunLocalTests — All tests in your org are run, except the ones that originate from installed managed and unlocked packages. This test level is the default, unless you specify --tests, in which case the default is RunSpecifiedTests. - RunAllTestsInOrg — All tests in your org are run, including tests of managed packages. diff --git a/src/commands/project/deploy/validate.ts b/src/commands/project/deploy/validate.ts index bc4b65c7..4636e826 100644 --- a/src/commands/project/deploy/validate.ts +++ b/src/commands/project/deploy/validate.ts @@ -102,7 +102,8 @@ export default class DeployMetadataValidate extends SfCommand TestLevel.RunSpecifiedTests, TestLevel.RunRelevantTests, ], - default: TestLevel.RunLocalTests, + default: async (context) => + Promise.resolve(context.flags.tests ? TestLevel.RunSpecifiedTests : TestLevel.RunLocalTests), description: messages.getMessage('flags.test-level.description'), summary: messages.getMessage('flags.test-level.summary'), helpGroup: testFlags,