I created an SFDX project with manifest in VSCODE, authorized my sandbox org and retrieved source from manifest on the default package.xml. At this point I had the base setup with classes, triggers, aura etc.. I only made a change to a class file, right click deploy source to org which deploys to my sandbox. Now I want to deploy to my production org, but I get the following error sf:INVALID_OPERATION: INVALID_OPERATION: testLevel of NoTestRun cannot be used in production organizations

How can I deploy this file to production?

1 Answer 1


As of Now

You can use sfdx force:source:deploy -l RunLocalTests ... to run tests. This will enable deploying source-formatted metadata directly to production.

Original Answer

As of Spring '19

force:source:deploy doesn't support deploying to production, as it always specifies to run no tests, and tests are required for deployment to production. You can either use unlocked packages force:package:install, or you can use force:source:convert followed by force:mdapi:deploy to deploy to production.

Note to future visitors: This feature may have been added after this answer was written. Be sure to check the documentation.

  • if I understand correctly, by using force:source:convert I will be zipping my current project and then deploying it, is that correct? When I originally did my retrieve source from manifest on the package.xml it pulled in classes, trigger etc.., I have only made a change to 1 specific class file. Is there a way to only package that specific file. I don't need to deploy everything.
    – MarkC5000
    Commented Apr 15, 2019 at 14:44
  • @MarkC5000 You'd have to copy the class to a new deploy folder, include the metadata file and package.xml, and deploy it. It'd be a lot easier at this point to just use a Change Set at this point.
    – sfdcfox
    Commented Apr 15, 2019 at 14:55
  • 1
    as of 10/19 source deploy has been updated to enable running tests. -l RunLocalTests is the option.
    – ebt
    Commented Oct 9, 2019 at 17:11
  • @ebt I knew about that, just forgot about this question. Thanks for reminding me, I'll update it.
    – sfdcfox
    Commented Oct 9, 2019 at 19:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .