Newer Version Available
How Lightning Testing Service Works
LTS consists of two major components:
- The LTS unmanaged package, listed by release version on the project Releases page
- The LTS install command for the Salesforce CLI
1yourInstance/c/jasmineTests.appWhen you run tests manually in a browser, you’re using only the pieces of LTS provided in the package.
For more sophisticated development processes, use the LTS commands included with the Salesforce DX CLI plugin. The Salesforce CLI allows you to integrate LTS into your automated testing, continuous integration, and other source-based development processes.
The command line tool automates running your test suites. It opens the same URL you can open manually, and uses WebDriver to observe the test suite as it runs. Then it parses and packages the results for use in command line-based development processes.
Installing LTS is a one line command in the Salesforce DX CLI. Once installed, you can work with your test suite in various ways from the command line.
Write your tests using a JavaScript testing framework of your choosing. We provide easy-to-use wrappers for Jasmine and Mocha.
A simple Jasmine test spec looks like the following:
1/**
2 * This is a 'hello world' Jasmine test spec
3 */
4describe("A simple passing test", function() {
5 it("checks that true is always true", function() {
6 expect(true).toBe(true);
7 });
8});A Mocha test looks similar.
1/**
2 * This is a 'hello world' Mocha test
3 */
4var assert = require('assert');
5 describe('A simple passing test', function() {
6 it('checks that true is always true', function() {
7 assert.equal(true, true);
8 });
9 });You can write your own wrapper if you prefer a different testing framework. It's not hard, but plan on half a day to a day of work.
LTS also provides utilities specific to the Lightning Component framework, which let you test behavior specific to Lightning components. Details are explained in comments in the example tests.
Your test suite is deployed in the form of an archive (zip) static resource. Once LTS is installed and configured, you make changes to your test suite, create the archive, and upload it to your org. Once uploaded you can run the test suite via the command line or via URL.