sfdk-emulator
Emulate Salesforce Functions locally for development
TLDR
Display the installed emulators
Start an emulator
Stop an emulator
Display emulator status
Run an interactive shell on an emulator
SYNOPSIS
sfdk-emulator [options] command [command-options]
PARAMETERS
--help
Displays help information about the command and its options.
--version
Displays the version number of the sfdk-emulator.
--config file_path
Specifies the path to the emulator configuration file. This file defines the behavior of the emulated SFDX commands.
command
The SFDX command to be emulated (e.g., `force:org:create`, `force:source:deploy`).
command-options
Options to pass to the SFDX command to be emulated (e.g., `--definitionfile config/project-scratch-def.json`).
DESCRIPTION
The `sfdk-emulator` command allows developers to simulate the behavior of Salesforce DX (SFDX) commands without requiring actual connectivity to a Salesforce org or the use of authorized connections. This is particularly useful for development and testing purposes, enabling faster iteration cycles by bypassing the time-consuming process of deploying and retrieving metadata from a live Salesforce environment. It is also useful for offline development and for automated CI/CD pipelines where real Salesforce org access is restricted or unavailable. The emulator can be configured to mock various SFDX commands, including authentication, metadata retrieval, and deployment. By providing a controlled environment, developers can validate their SFDX scripts, configurations, and deployment packages before deploying them to a production or sandbox org. The `sfdk-emulator` reduces dependencies on external Salesforce environments and promotes more reliable and repeatable testing.
CAVEATS
The `sfdk-emulator` provides a simulation of SFDX commands. It does not interact with a real Salesforce org. The accuracy of the emulation depends on the configuration file provided. Unexpected behavior may occur if the configuration file is not properly configured or if the emulator does not fully support a specific SFDX command or option.
CONFIGURATION FILE
The configuration file for `sfdk-emulator` is typically a JSON file that maps SFDX commands and options to predefined responses. This allows you to control the output and behavior of the emulated commands. This file should mimic the sfdx cli JSON response.
EXAMPLE USAGE
To emulate the `force:org:create` command:
sfdk-emulator --config config.json force:org:create --definitionfile config/project-scratch-def.json --targetdevhubusername myDevHub@example.com --setalias MyScratchOrg --durationdays 7
AUTHENTICATION
The emulator does not perform actual authentication against a Salesforce org. Instead, the configuration file should specify a mock authentication response.