Empowering Salesforce Development: A Journey into Frontend – Lightning Web Components (LWC) Testing
Amit Kumar Tiwari
Head of Salesforce Architecture & Practice | Delivering largest Salesforce Implementation for Wealth | Architect Leader | FinTech | Design Thinker | DevSecOps Advocate | Salesforce SME | AgilePM | Open-Source Evangelist
Welcome to the Salesforce – Lightning Web Components (LWC) world.
Lightning Web Components are a user interface (UI) framework that Salesforce Developers use to create customized pages and functions on the Salesforce Platform.
Over the past couple of years, LWC has evolved significantly, and its global usage has increased tremendously, surpassing custom UI development and Aura usage.
I can confidently say that imagining front-end development without LWC is no longer possible; LWC has truly become the “key thing” for Salesforce Developers.
Advantages of using LWC
Fortunately, in our Salesforce Practice at intellectAI , we are already a frontrunner in using LWC for our customers’ experience ??.
While, for the past couple of months, we have been diligently working on our Frontend (UI UX) – Lightning Web Components (LWC) Testing. And, we have realized that there is still work to be done in the Salesforce frontend development space compared to the maturity of Salesforce backend (APEX) development.
We have a unit testing framework in place for APEX code, with a mandate of a minimum 75% code coverage for deployment, while we still lack a mechanism for the frontend development.
Recently, to strengthen our frontend code practice, we have completed the implementation of the 'JavaScript Testing Framework (JEST)'.
领英推荐
JEST is a JavaScript Testing framework designed to ensure correctness of any JavaScript codebase.
I can say that this implementation was quite successful for us, primarily because of the following two key points:
This enables us to set up a system for our development team to write
“LWC Test Classes” during component development itself,
similar to the APEX Test Classes for APEX components.
This enables us to achieve 'automated quality control' by running
the frontend test classes and determining whether to “accept/reject”
the build based on JEST results during deployment.
(similar to what we have for Static Code Analyzer (SCA) as described in my earlier post)
We were looking for a system to ‘accept/reject’ a build (from a front-end testing basis) for quite some time. Similarly, providing a platform to developers to write 'LWC test classes' to verify their front-end code before committing it to the Version Control System (VCS) is a game-changer for us. This not only enhances our frontend testing, but overall it helps our testing efforts to shift-left, allowing developers to initiate early testing.
While bringing this into the picture, there were quite serious challenges as well. We found making the team ready to write 'proper frontend test classes' regularly is a massive Dev Practice and Programming Culture change. It takes us time to nail it, but our adaptive implementation strategy with training sessions and documentation helps us get there. Cheers!
For any further insights or to start a conversation about how we achieved this and how this can support your Salesforce endeavours, feel free to reach out.