Do we need test class for lightning component?

Do we need test class for lightning component?

Because Lightning components often contain client-side Javascript controllers, you need to test that logic. Apex is a proprietary language, so Salesforce provides built-in testing tools with the Lightning Platform. Jasmine is a behavior-driven development testing framework.

What is lightning Testing Service?

The Lightning Testing Service, or LTS, is a set of tools and services that let you create test suites for your Aura components using standard JavaScript test frameworks, such as Jasmine and Mocha.

How to call an apex class from a lightning component?

Now, let’s go ahead and define an apex class that can be used by this lightning component. The apex class should simply return the list of Account records with the Name and Type fields. To keep things simpler, we will just query the first 10 accounts using the LIMIT operator.

How to write unit tests on the Lightning Platform?

Write unit tests for Lightning components. Development on the Lightning Platform these days includes more than just Apex. It includes client-side Javascript in Lightning component controllers. Testing these involves a few specialized tools. This video introduces them. Lightning components are the building blocks of modern Salesforce applications.

Which is the helper object in Lightning test?

One of the first things that happens in the test is a call to $T, the test helper object. In this case, you’re using $T to create an instance of the component c:egClientSideAction. $T is promise enabled, meaning the real work of your test is contained in the .then (component) method starting on line 72.

How to do unit testing in Salesforce Lightning?

In the Developer Console’s jasmineExampleTest.js tab, scroll down to the test suite starting on line 69. This test demonstrates invoking a client-side action and inspecting its behavior. One of the first things that happens in the test is a call to $T, the test helper object.