Newer Version Available
Explore the Example Test Suites
Open the test suite file in one window, and in another window (perhaps in your IDE) open the simple components being tested.
The components and the test suites included in the unmanaged package are also available in a repository on GitHub.
https://github.com/forcedotcom/LightningTestingService
Components for Testing
All of the testable components have names beginning with “eg” (from the abbreviation “e.g.”, meaning for example). They contain extensive comments to guide you through each one. Access the components provided in the package as you would access any Aura component.
- In the Developer Console
- In the Force.com IDE, in the /aura/ directory
- By converting your org’s metadata into a format that you can work with locally, using Salesforce DX
- Directly from the LightningTestingService repo in the lightning-component-tests/main/default/aura directory.
We include more than a dozen components, designed to be used in illustrative tests. Each of the components has a description of its behavior in its .auradoc documentation file.
Test Suites
The example tests are included in static resources. You can also review them directly in the LightningTestingService repo, in the lightning-component-tests/test/default/staticresources directory.
The LTS package includes four test suites, three for Jasmine and one for Mocha:
- jasmineHelloWorldTests.resource—A very simple Jasmine example including one passing and one failing test.
- jasmineExampleTests.resource—The main Jasmine example test suite.
- jasmineLightningDataServiceTests.resource—Some Jasmine examples specific to testing Lightning Data Service-based components.
- mochaExampleTests.resource—The Mocha example test suite, which provides examples parallel to the main Jasmine test suite.
The jasmineExampleTests.resource and mochaExampleTests.resource files are each a single JavaScript file containing a complete test suite. These are single files for convenience in delivery and exploration. Your own test suites can include many such files. The test suites are copiously commented to help you learn.
This directory also exposes the $T utility object. This object has methods that simplify routine testing operations. Notice that these methods are used throughout the example test scripts in the repo.
The remaining static resources are infrastructure used by LTS. They’re briefly described in Use Other Frameworks.