README
@lwc/jest-preset
Tools to assist with testing Lightning Web Components (LWC) with Jest. This project provides 2 services: preset Jest configuration for testing Lightning web components, and stubs for common external libraries used in Lightning web components.
Usage
Installation
yarn add --dev @lwc/jest-preset @lwc/compiler @lwc/engine-dom @lwc/synthetic-shadow
Configuration
Add the preset to your jest.config.js
like so:
{
"jest": {
"preset": "@lwc/jest-preset"
}
}
Then, update the moduleNameMapper
entry in jest.config.js
to point to where your LWC components live. For example, use the following to map all components in the example
and other
namespaces:
{
"moduleNameMapper": {
"^(example|other)/(.+)