Skip to content

salesforcecli/plugin-lwc-test

@salesforce/sfdx-plugin-lwc-test

Tools for unit testing Lightning web components in a Salesforce DX workspace

Usage

Install as a plugin in the Salesforce CLI. While this plugin is in pilot you will need to manually install the plugin into your CLI.

$ sfdx plugins:install @salesforce/sfdx-plugin-lwc-test
$ sfdx force:lightning:lwc:test --help

Commands

sfdx force:lightning:lwc:test:create -f <string> [--json] [--loglevel trace|debug|info|warn|error|fatal]

create a Lightning web component test with boilerplate code inside a tests directory

USAGE
  $ sfdx force:lightning:lwc:test:create -f <string> [--json] [--loglevel trace|debug|info|warn|error|fatal]

OPTIONS
  -f, --filepath=filepath                         (required) path to Lightning web component .js file to create a test
                                                  for

  --json                                          format output as json

  --loglevel=(trace|debug|info|warn|error|fatal)  [default: warn] logging level for this command invocation

EXAMPLE
  $ sfdx force:lightning:lwc:test:create -f force-app/main/default/lwc/myButton/myButton.js

See code: src/commands/force/lightning/lwc/test/create.ts

sfdx force:lightning:lwc:test:run [-d] [--watch] [--json] [--loglevel trace|debug|info|warn|error|fatal]

invoke Lightning web component Jest unit tests

USAGE
  $ sfdx force:lightning:lwc:test:run [-d] [--watch] [--json] [--loglevel trace|debug|info|warn|error|fatal]

OPTIONS
  -d, --debug                                     run tests in debug mode
  --json                                          format output as json
  --loglevel=(trace|debug|info|warn|error|fatal)  [default: warn] logging level for this command invocation
  --watch                                         run tests in watch mode

EXAMPLES
  $ sfdx force:lightning:lwc:test:run
  $ sfdx force:lightning:lwc:test:run -w

See code: src/commands/force/lightning/lwc/test/run.ts

sfdx force:lightning:lwc:test:setup [--json] [--loglevel trace|debug|info|warn|error|fatal]

install Jest unit testing tools for Lightning web components

USAGE
  $ sfdx force:lightning:lwc:test:setup [--json] [--loglevel trace|debug|info|warn|error|fatal]

OPTIONS
  --json                                          format output as json
  --loglevel=(trace|debug|info|warn|error|fatal)  [default: warn] logging level for this command invocation

EXAMPLE
  $ sfdx force:lightning:lwc:test:setup

See code: src/commands/force/lightning/lwc/test/setup.ts

About

Tools for unit testing Lightning web components in a Salesforce DX workspace

Resources

License

MIT, BSD-3-Clause licenses found

Licenses found

MIT
LICENSE
BSD-3-Clause
LICENSE.txt

Code of conduct

Stars

Watchers

Forks

Packages

No packages published