18

By scrolling through the Lightning Reference, I've found that there's an Aura Javascript API class called Test. You can find the API docs at https://na24.lightning.force.com/auradocs/reference.app#reference?topic=api:Test.

The docs are...sparse to say the least. The documentation for the Aura open source framework seems to say you can create a MyComponentTest.js file in your component bundle with tests, but no tool I can find successfully deploys a test class to Salesforce.

Is there a way to write test classes into my Controller that are called when certain events fire? Or are we stuck waiting for Salesforce to support this aspect of Aura?

11

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.

  • 1
    That's what I get for being an early adopter! – Christian Carter Jul 4 '15 at 19:06
  • 1
    Besides being awesome that is. – Kris Gray Jul 4 '15 at 20:13
  • @KrisGray is there any way to create a hybrid development environment that uses a client-side installation of the framework for unit testing while still saving the main resources in the component bundle to Salesforce? – abd3721 Oct 14 '15 at 12:42
  • Yes and no. Aura is open source, and you can setup an instance of it to test with. But you'd have to manually copy over everything after that. See this link for more info on setting it up if you want. developer.salesforce.com/blogs/developer-relations/2015/06/… – Kris Gray Oct 14 '15 at 20:13
  • 1
    @KrisGray Has there been any update on this? When can we expect official support for unit testing Lightning? – Steve Buikhuizen May 4 '16 at 3:27
3

I needed a solution for this so I built https://github.com/stevebuik/greased Let me know what you think.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.