lwc-testing

Standardize Jest-based testing patterns for Salesforce Lightning Web Components.

2|Updated Mar 18, 2026
One-click install
npx skills add https://github.com/bhanu91221/claude-sfdx-iq --skill lwc-testing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: lwc-testing
Source: https://github.com/bhanu91221/claude-sfdx-iq/tree/main/skills/lwc-testing
Command: npx skills add https://github.com/bhanu91221/claude-sfdx-iq --skill lwc-testing

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Automate and standardize Jest-based testing for Salesforce Lightning Web Components to reduce boilerplate and catch regressions early.

Core Features & Use Cases

  • Setup and configuration patterns for sfdx-lwc-jest in Salesforce projects.
  • Tests for LWC components including wire adapters, LDS, and DOM querying.
  • Utilities and patterns for testing events, promises, and mocked Salesforce modules.
  • Real-world examples and test data patterns to accelerate test authoring.

Quick Start

Install the required testing framework and start by adding a basic test under force-app/main/default/lwc/YourComponent/tests for your first test.

Frequently Asked Questions about lwc-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I test Lightning Web Components with Jest in Salesforce?

Jest testing for Lightning Web Components is done using the sfdx-lwc-jest framework. It provides standardized patterns for setup, wire adapters, DOM querying, and mocked modules to catch regressions early.

What is the best way to mock wire adapters in LWC Jest tests?

Mocking wire adapters in LWC Jest tests is handled through specialized utilities that intercept Lightning Data Service calls. This allows you to control test data patterns and simulate server responses without backend Apex calls.

Do I need sfdx-lwc-jest to test LWC components?

sfdx-lwc-jest is required for LWC component testing. It provides the necessary Jest configuration and environment to run tests within a proper Salesforce project layout, ensuring LDS and shadow DOM function correctly.

How do I test DOM queries and events in Salesforce LWC?

Testing DOM queries and events in Salesforce LWC involves querying shadow DOM elements and dispatching custom events within your test file. These patterns validate component interactions and promise resolutions using mocked data.

Where do I place Jest test files in an LWC Salesforce project?

Jest test files in an LWC Salesforce project are placed under the __tests__ directory within your component folder. This structure is located at force-app/main/default/lwc/YourComponent/__tests__ for proper recognition.

Why use Jest for LWC testing instead of other testing frameworks?

Jest for LWC testing reduces boilerplate by providing built-in mocking for Salesforce modules and native support for shadow DOM queries. It standardizes test authoring compared to generic JavaScript testing frameworks.