You need to sign in to do that
Don't have an account?
Naoki 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?
thanks.
thanks.
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 ,
for example:
xxx.cmp
<aura:component>
<ltng:require styles="" scripts="/resource/myAngularJS" />
xxController.js
xx: function(cmp, evt, helper){
//call a function in myAngularJS.js
myMainLogic.xxxx(cmp, evt);
}
myAngularJS.js
/* 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.
Thanks.
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.
See my article here: https://www.linkedin.com/pulse/testing-lightning-components-outside-salesforce-yuriy-sannikov
https://github.com/yury-sannikov/mocha-aura