I asked about the difference between controller and helper and it prompted me to ask another, more specific set of questions:

  1. What is the best way to reuse JavaScript code across Lightning Components?
  2. What is the best way to test JavaScript code within Lightning Components?
  3. Do Lightning JavaScript files (Controller, Helper, Renderer, etc) have corresponding metadata components? I would like to pull this down via IDE for version control.

My main doubts around the platform revolve around how it fits in with our best practices of unit testing and code review, so answers to these questions could go a long way towards helping me cement it or eliminate it as an option. Thanks!

4 Answers 4


1. Reuseability

Helper.js is a good thing to share code within a bundle - but not across many bundles. I think a strong library concept is still missing. Actually it's not possible to use CDN due to CSP but they are planning to introduce whitelists. It even looks like whitelists could be already possible:

Requesting CSP Exceptions

If your app is not working due to a CSP violation, contact Salesforce to request a CSP exception for your org. Include the violation message from your browser's developer console in any communication.

You can use Static Resources to provide libraries (package- or org-wide).

2. Testing

since it's very js-centric you might use some JS testing frameworks - but I expect salesforce to deliver here somthing.

3. Metadata / IDEs

All the Lightning metadata is available via Tooling API:

Alternatively access via Metadata API is working, too.

As far as I know, Force.com IDE still missing Lightning support. I think they are still on v30 or v31

You might also try a plugin for sublime/Mavensmate.

And CodeFusion actually does support Lightning since last year - however by design still without local files ;-)

But you need this package for lightning support - both, metadata and tooling API (v32) is supported.

I always planned to write a version control integration, but probably before that happens I'm going to open source the project.

A really cool thing about Lightning is the speed for saving files. It's not like apex or visualforce which needs about 3 to 10 seconds to save. Try saving a Lightning file it usually takes 0.300 to 0.800 seconds. First time fun coding! Doug's team unleashed a turbo here.

  • 3
    Great answer - thanks Uwe - on the CSP exception policy it is very important to note that if your components require disabling of CSP to operate they will not pass our security review for publication to app exchange. I recently worked with an ISV that needed to leverage Google maps and it was fairly simple to use an iframe from a separate domain based proxy to host the map and a small amount of postMessage() based logic to provide a secure solution to that specific scenario. Feb 28, 2015 at 11:03
  • 3
    Whitelisting is something we are discussing - I actually expected that to be a fairly non controversial feature but our security team has very strong reservations about this. Feb 28, 2015 at 11:06

I've found using Jasmine (a Javascript testing framework) is a good way to go for Unit Testing my Lightning Components. There was a recent Dreamforce session which showcased using Jasmine with Lightning Components (and the modifications required to get it working with LockerService enabled). Given that the testing side of the Aura framework hasn't been exposed yet in the dev tools, I've been pushing the use of Jasmine on the projects I've been involved with due to past experience with it.

For more information please visit the following links:


The best IDE combo I've found is Sublime3, using MavensMate for all non-lightning development coupled with:

Dave Carroll's Lightning Plugin

This has the added bonus of letting me easily push to github from my local machine. Also, I asked some of the Salesforce dev at a recent event what IDE they used, and this setup was what they said they all used internally.


For testing you can now try https://github.com/stevebuik/greased Let me know what you think

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .