Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Lightning Testing Service

7,363 views

Published on

This is my presentation used for the session at TDX18GG organized by New Delhi India, Non Profit User Group. For a more detailed explanation about the session, visit this blog:- https://sfdcstop.blogspot.com/2018/05/lightningtestingservice.html

Published in: Software
  • D0WNL0AD FULL ▶ ▶ ▶ ▶ http://1lite.top/7Xh5a ◀ ◀ ◀ ◀
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Lightning Testing Service

  1. 1. Test your lightning components using Lightning Testing Service - Rahul Malhotra
  2. 2. About Me  Software Engineer Trainee & a part of Center of Excellence Team at SaaSfocus  Independent Salesforce Consultant  Blogger and YouTuber at SFDC Stop
  3. 3. Today’s Agenda  Need of testing our Lightning Component  Introduction to Lightning Testing Service  Jasmine & Mocha – Understanding syntax  Live Demo - Lightning Testing Service  Considerations for Lightning Testing Service  Available resources to learn LTS  Q & A
  4. 4. Need for Testing Lightning Components  With the introduction of Salesforce Lightning, we started to keep data at the client side  This approach is necessary to reduce the number of server calls and provide a rich User Experience to customer  Salesforce introduced methods and actions to promote storing data at client side cache to reduce server calls. For Ex:- Storable Actions  This made our lightning components more responsible for handling data  To make sure our application or component work properly with different variety of input data, testing is important
  5. 5. Lightning Testing Service – An Introduction  Lightning Testing Service (LTS) is a set of tools and services that let you create test suites for your lightning components using standard JavaScript frameworks, such as Jasmine and Mocha  At present, Salesforce provides wrappers for Jasmine and Mocha testing framework however if you like any other framework, you can write a wrapper for it too by yourself  LTS provides utilities specific to lightning component framework to test behavior specific to lightning components  You can install LTS using Salesforce DX commands or it is also available as an unmanaged package. You can find the latest releases of LTS on the releases page on GitHub and install directly from there
  6. 6. Jasmine & Mocha – Understanding Syntax /** * This is a 'hello world' Jasmine test spec */ describe("A simple passing test", function() { it("checks that true is always true", function() { expect(true).toBe(true); }); }); /** * This is a 'hello world' Mocha test */ var assert = require('assert'); describe('Test the nature of truth', function() { describe('A simple passing test', function() { it('checks that true is always true', function() { assert.equal(true, true); }); }); }); Jasmine Mocha
  7. 7. It’s Time to Code
  8. 8. Considerations for Lightning Testing Service  Data inserted in the org while testing is not rolled back or deleted automatically  In some scenarios, you have to make changes in your existing lightning component to make it ready to be used for testing  Presently, Salesforce has provided wrappers for Jasmine and Mocha Framework however, if you want to use any other testing framework, you are free to use it but you have to write your own wrapper for that.
  9. 9. Resources  Documentation:- https://forcedotcom.github.io/LightningTestingService/  GitHub Repository:- https://github.com/forcedotcom/LightningTestingService  Salesfoce Blog:- https://developer.salesforce.com/blogs/2018/04/getting- started-with-the-lightning-testing-service.html  SFDC Stop:- https://sfdcstop.blogspot.com/2018/05/lightningtestingservice.html
  10. 10. Q & A
  11. 11. Thank You  GitHub Repository Link:- https://github.com/rahulmalhotra/LightningTestingService  My Twitter Handle:- @rahulcoder  Blog:- https://sfdcstop.blogspot.com  YouTube Channel:- https://www.youtube.com/c/SFDCStop  Salesforce Chatter:- http://bit.ly/rahulforce

×