sf-lwc-testing

Write and debug LWC Jest tests with component mounting and Apex mocking.

13|2|Updated Mar 18, 2026
One-click install
npx skills add https://github.com/jiten-singh-shahi/salesforce-claude-code --skill sf-lwc-testing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sf-lwc-testing
Source: https://github.com/jiten-singh-shahi/salesforce-claude-code/tree/main/.cursor/skills/sf-lwc-testing
Command: npx skills add https://github.com/jiten-singh-shahi/salesforce-claude-code --skill sf-lwc-testing

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a dedicated framework for writing and debugging Lightning Web Components (LWC) tests using Jest. It covers component mounting, wire and Apex mocking, and user interaction verification to ensure reliable, deterministic test results.

Core Features & Use Cases

  • Component rendering and lifecycle validation
  • Wire adapter and Apex call mocking for isolated unit tests
  • Interaction simulation, toast/navigation verification, and test scaffolding for LWC projects

Quick Start

Install @salesforce/sfdx-lwc-jest, configure your test environment, and place your first tests under tests to begin testing.

Frequently Asked Questions about sf-lwc-testing

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

FAQPage Schema
How do I mock Apex calls in LWC Jest tests?

Mocking wire adapters in LWC Jest tests involves replacing Lightning Message Service or data provider adapters with custom test data. This ensures component lifecycle validation produces deterministic, isolated test results.

How do I mock wire adapters in LWC Jest tests?

Mocking wire adapters in LWC Jest tests involves replacing data provider adapters with custom test data payloads. This ensures component lifecycle validation produces deterministic, isolated unit test results.

What's the best way to simulate user interactions in Lightning Web Components testing?

Simulating user interactions in Lightning Web Components testing requires dispatching DOM events to mounted elements. This verifies interaction simulation, toast notifications, and navigation behavior within your Jest test suite.

Do I need @salesforce/sfdx-lwc-jest to run LWC component tests?

Yes, you need @salesforce/sfdx-lwc-jest along with a Node.js environment to run and validate LWC component tests. These dependencies provide the standard test patterns required for component rendering and mocking.

Why are my LWC Jest tests failing due to navigation or toast errors?

LWC Jest tests fail with navigation or toast errors when these services are not properly mocked in your test file. You must stub navigation and toast events to ensure reliable, deterministic test results.