# @salesforce/sfdx-plugin-lwc-test

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

Latest version **1.2.1** (published 2024-10-04) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install @salesforce/sfdx-plugin-lwc-test
pnpm add @salesforce/sfdx-plugin-lwc-test
yarn add @salesforce/sfdx-plugin-lwc-test
bun add @salesforce/sfdx-plugin-lwc-test
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2024-10-04 |
| First published | 2019-08-07 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=14.0.0 |
| Dependencies | 7 |
| Unpacked size | 1020.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | lwc-admin, dme722, nolanlawson, ire-npm-team-user, jburnie, abirchfieldsfdc, dlouvton, mobify, jmsjtu, jasonschroeder-sfdc, packagellama, maward, danielshox, duane.chew, dferro, jcourtner, jye-sf, adirasanam, hkii, iamaziz, dbreese-salesforce, ashokrudraraju, dhersam, demianbrecht, mbettio, damilareolowoniyi, mmadialagan, mjrust, salesforce-releases, kevinv11n, byao, pmdartus, ekashida, ravi.jayaramappa, apapko, jleen-sfdc, jqian, cwallsf, dhagberg-sf, khawkins, amphro, jodarove, sfdctaka, fernomac, jimjag, ivarley, jbartolotta-sfdc |
| Keywords | sfdx-plugin |

## Links

- npm: https://www.npmjs.com/package/@salesforce/sfdx-plugin-lwc-test
- Repository: https://github.com/salesforce/sfdx-plugin-lwc-test
- Homepage: https://github.com/salesforce/sfdx-plugin-lwc-test#readme
- Issues: https://github.com/salesforce/sfdx-plugin-lwc-test/issues
- npm.io page: https://npm.io/package/@salesforce/sfdx-plugin-lwc-test

## Dependencies (7)

- [tslib](https://npm.io/package/tslib.md) ^2.3.1
- [@oclif/core](https://npm.io/package/@oclif/core.md) ^1.16.0
- [signal-exit](https://npm.io/package/signal-exit.md) ^3.0.6
- [semver-compare](https://npm.io/package/semver-compare.md) ^1.0.0
- [@salesforce/kit](https://npm.io/package/@salesforce/kit.md) ^1.6.0
- [@salesforce/core](https://npm.io/package/@salesforce/core.md) ^3.26.2
- [@salesforce/command](https://npm.io/package/@salesforce/command.md) ^5.2.6

## Recent versions

- 1.2.1 (latest) — 2024-10-04
- 1.0.2-beta.1 (beta) — 2023-04-17
- 1.2.0 — 2024-03-05
- 1.1.1 — 2023-10-24
- 1.1.0 — 2023-09-11
- 1.0.2 — 2023-04-17
- 1.0.1 — 2022-09-01
- 1.0.0 — 2022-06-30
- 0.1.7 — 2020-07-08
- 0.1.6 — 2020-05-14
- 0.1.5 — 2020-02-18
- 0.1.4 — 2020-02-18
- 0.1.3 — 2019-10-24
- 0.1.1 — 2019-08-09
- 0.1.0 — 2019-08-07

## README

@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](https://developer.salesforce.com/tools/sfdxcli). While this plugin is in pilot you will need to manually install the plugin into your CLI.
```sh-session
$ 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](https://github.com/trevor-bliss/sfdx-lwc-test/blob/v0.0.6/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](https://github.com/trevor-bliss/sfdx-lwc-test/blob/v0.0.6/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](https://github.com/trevor-bliss/sfdx-lwc-test/blob/v0.0.6/src/commands/force/lightning/lwc/test/setup.ts)_

---
_Source: https://npm.io/package/@salesforce/sfdx-plugin-lwc-test · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
