function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Naoki KitaarashiNaoki Kitaarashi 

Are there any recommendation for unit-test Lightning component.

Lightning component consists of HTML part and JavaScript part. I can debug and test Lightning app running on browser but I don't find the way to unit test JS part of Lightning component such as controller and helper.  I think it best to test that using popular js testing tool like QUnit or Jasmine. Does someone know how Lightning developer team test their own component(ltng:xx) to enhance it's quality?

Hi Naoki, 
In lightning document they have not mentioned any unit test for controller and helper. In salesforce, test class is only available for apex controller to do the unit testing ,
Naoki KitaarashiNaoki Kitaarashi
Thanks Rishav for your comment. Feel disappointed to hear that there is no unit testing in developing Lightning component. I think getting high quality software always need doing unit testing so unit testing culture starting form JUnit in java has spreaded over other languages. An idea I just think of is not implement all Js code in controller or helper module and move main logic to normal js module which is included in cmp file.

for example:

    <ltng:require styles="" scripts="/resource/myAngularJS" />

  xx: function(cmp, evt, helper){
    //call a function in myAngularJS.js
     myMainLogic.xxxx(cmp, evt);

   /* this is normal java script usin AngularJS
  myMainLogic = {
    xx: function(cmp, evt){

In this approach, controller or helper just include simple event handling logic which doesn't need unit testing and call functions implemented in other JS file which can be unit-tested in Qunit or Jasmint.

Andrew B. DavisAndrew B. Davis
There actually is a built-in unit testing framework for Aura, the technology on which Lightning components are based. There's documentation on that here ( According to this response ( from one of the Lightning Components developers, "This functionality has not been exposed yet. The Aura framework supports it just fine, but getting that wired into the Dev Tools for Lightning in Salesforce is a bit more involved."

I have not done it myself, but it seems that you could setup a local unit testing stack for Lightning Components and write and run unit tests using that, while everyone waits for the official inclusion of this functionality into Salesforce.
Steve BuikhuizenSteve Buikhuizen
Maybe give this a try
Yury SannikovYury Sannikov
I'm using mocha.js to test non-UI code base outside of Salesforce at all.
See my article here: