lightning Commands

Use the lightning commands to create and test Lightning component bundles.

lightning:app:create

Creates a Lightning app bundle in the specified directory or the current working directory. The bundle consists of multiple files in a folder with the designated name.

Command Syntax

sfdx force:lightning:app:create
-n APPNAME
[-t TEMPLATE]
[-d OUTPUTDIR]
[-a APIVERSION]
[--json]
[--loglevel LOGLEVEL]

Parameters

-n | --appname APPNAME
Required




The Lightning app name. The name can be up to 40 characters and must start with a letter.

Type: string
-t | --template TEMPLATE
Optional




The template to use to create the file. Supplied parameter values or default values are filled into a copy of the template.

Type: string
Permissible values are: DefaultLightningApp
Default value: DefaultLightningApp
-d | --outputdir OUTPUTDIR
Optional




The directory to store the newly created files. The location can be an absolute path or relative to the current working directory. The default is the current directory.

Type: string
-a | --apiversion APIVERSION
Optional




The API version of the created source.

Type: string
Permissible values are: 40.0, 39.0
Default value: 40.0
--json
Optional




Formats output as JSON.

Type: string
--loglevel LOGLEVEL
Optional




The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: error

Help for lightning:app:create

If not supplied, the apiversion, template, and outputdir use default values.

The outputdir can be an absolute path or relative to the current working directory.

Examples:

1$ sfdx force:lightning:app:create -n myapp
1$ sfdx force:lightning:app:create -n myapp -d lightning

lightning:component:create

Creates a Lightning component bundle in the specified directory or the current working directory. The bundle consists of multiple files in a folder with the designated name.

Command Syntax

sfdx force:lightning:component:create
-n COMPONENTNAME
[-t TEMPLATE]
[-d OUTPUTDIR]
[-a APIVERSION]
[--json]
[--loglevel LOGLEVEL]

Parameters

-n | --componentname COMPONENTNAME
Required




The Lightning component name. The name can be up to 40 characters and must start with a letter.

Type: string
-t | --template TEMPLATE
Optional




The template to use to create the file. Supplied parameter values or default values are filled into a copy of the template.

Type: string
Permissible values are: DefaultLightningCmp
Default value: DefaultLightningCmp
-d | --outputdir OUTPUTDIR
Optional




The directory to store the newly created files. The location can be an absolute path or relative to the current working directory. The default is the current directory.

Type: string
-a | --apiversion APIVERSION
Optional




The API version of the created source.

Type: string
Permissible values are: 40.0, 39.0
Default value: 40.0
--json
Optional




Formats output as JSON.

Type: string
--loglevel LOGLEVEL
Optional




The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: error

Help for lightning:component:create

If not supplied, the apiversion, template, and outputdir use default values.

The outputdir can be an absolute path or relative to the current working directory.

Examples:

1$ sfdx force:lightning:component:create -n mycomponent
1$ sfdx force:lightning:component:create -n mycomponent -d lightning

lightning:event:create

Creates a Lightning event bundle in the specified directory or the current working directory. The bundle consists of multiple files in a folder with the designated name.

Command Syntax

sfdx force:lightning:event:create
-n EVENTNAME
[-t TEMPLATE]
[-d OUTPUTDIR]
[-a APIVERSION]
[--json]
[--loglevel LOGLEVEL]

Parameters

-n | --eventname EVENTNAME
Required




The Lightning event name. The name can be up to 40 characters and must start with a letter.

Type: string
-t | --template TEMPLATE
Optional




The template to use to create the file. Supplied parameter values or default values are filled into a copy of the template.

Type: string
Permissible values are: DefaultLightningEvt
Default value: DefaultLightningEvt
-d | --outputdir OUTPUTDIR
Optional




The directory to store the newly created files. The location can be an absolute path or relative to the current working directory. The default is the current directory.

Type: string
-a | --apiversion APIVERSION
Optional




The API version of the created source.

Type: string
Permissible values are: 40.0, 39.0
Default value: 40.0
--json
Optional




Formats output as JSON.

Type: string
--loglevel LOGLEVEL
Optional




The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: error

Help for lightning:event:create

If not supplied, the apiversion, template, and outputdir use default values.

The outputdir can be an absolute path or relative to the current working directory.

Examples:

1$ sfdx force:lightning:event:create -n myevent
1$ sfdx force:lightning:event:create -n myevent -d lightning

lightning:interface:create

Creates a Lightning interface bundle in the specified directory or the current working directory. The bundle consists of multiple files in a folder with the designated name.

Command Syntax

sfdx force:lightning:interface:create
-n INTERFACENAME
[-t TEMPLATE]
[-d OUTPUTDIR]
[-a APIVERSION]
[--json]
[--loglevel LOGLEVEL]

Parameters

-n | --interfacename INTERFACENAME
Required




The Lightning interface name. The name can be up to 40 characters and must start with a letter.

Type: string
-t | --template TEMPLATE
Optional




The template to use to create the file. Supplied parameter values or default values are filled into a copy of the template.

Type: string
Permissible values are: DefaultLightningIntf
Default value: DefaultLightningIntf
-d | --outputdir OUTPUTDIR
Optional




The directory to store the newly created files. The location can be an absolute path or relative to the current working directory. The default is the current directory.

Type: string
-a | --apiversion APIVERSION
Optional




The API version of the created source.

Type: string
Permissible values are: 40.0, 39.0
Default value: 40.0
--json
Optional




Formats output as JSON.

Type: string
--loglevel LOGLEVEL
Optional




The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: error

Help for lightning:interface:create

If not supplied, the apiversion, template, and outputdir use default values.

The outputdir can be an absolute path or relative to the current working directory.

Examples:

1$ sfdx force:lightning:interface:create -n myinterface
1$ sfdx force:lightning:interface:create -n myinterface -d lightning

lightning:test:create

Creates a Lightning test in the specified directory or the current working directory. The .resource file and associated metadata file are created.

Command Syntax

sfdx force:lightning:test:create
-n TESTNAME
[-t TEMPLATE]
[-d OUTPUTDIR]
[--json]
[--loglevel LOGLEVEL]

Parameters

-n | --testname TESTNAME
Required




The name of the new Lightning test. The name can be up to 40 characters and must start with a letter.

Type: string
-t | --template TEMPLATE
Optional




The template to use to create the file. Supplied parameter values or default values are filled into a copy of the template.

Type: string
Permissible values are: DefaultLightningTest
Default value: DefaultLightningTest
-d | --outputdir OUTPUTDIR
Optional




The directory to store the newly created files. The location can be an absolute path or relative to the current working directory. The default is the current directory.

Type: string
--json
Optional




Formats output as JSON.

Type: string
--loglevel LOGLEVEL
Optional




The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: error

Help for lightning:test:create

The outputdir can be an absolute path or relative to the current working directory.

Examples:

1$ sfdx force:lightning:test:create -n MyLightningTest
1$ sfdx force:lightning:test:create -n MyLightningTest -d lightningTests

lightning:test:run

Runs Lightning component tests. The Lightning Testing Service (LTS) unmanaged package must be installed in your org. For details, see the LTS documentation.

Command Syntax

sfdx force:lightning:test:run
[-a APPNAME]
[-d OUTPUTDIR]
[-r RESULTFORMAT]
[-f CONFIGFILE]
[-o]
[-t TIMEOUT]
[-u TARGETUSERNAME]
[--json]
[--loglevel LOGLEVEL]

Parameters

-a | --appname APPNAME
Optional




Name of your Lightning test application. The name is case insensitive, and ".app" is optional, so "Test" and "test.app" are equivalent.

Default value: Test.app

Type: string
-d | --outputdir OUTPUTDIR
Optional




Directory path to store test run artifacts: log files, test results, etc.

Type: directory
-r | --resultformat RESULTFORMAT
Optional




Format to use when displaying test results. If you also specify the --json flag, --json overrides this parameter.

Type: string
Permissible values are: human, tap, junit, json
Default value: human
-f | --configfile CONFIGFILE
Optional




Path to a test configuration file to configure WebDriver and other settings. For details, see the LTS documentation.

Type: filepath
-o | --leavebrowseropen
Optional




Leaves browser open after the test finishes so that you can view the test suite results.

Type: flag
-t | --timeout TIMEOUT
Optional




Time, in milliseconds, to wait for the results element to be present in the DOM, before failing and moving on to the next test.

Type: number
Default value: 20000
-u | --targetusername TARGETUSERNAME
Optional




Username for the target org. Overrides the default target org.

Type: string
--json
Optional




Format output as JSON.

Type: flag
--loglevel LOGLEVEL
Optional




The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: error

Help for lightning:test:run

Examples:

1$ sfdx force:lightning:test:run
1$ sfdx force:lightning:test:run -a tests -r human
1$ sfdx force:lightning:test:run -f config/myConfigFile.json -d testResultFolder