Title: LIGHTNING COMPONENT TESTING WITH JASMINE
1- Lightning Component Testing with Jasmine
- Jasmine is a behaviour-driven development
framework - that is used for the purpose of
testing Javascript code.
2What are the Advantages ?
- Some advantages that Jasmine offers are
- It is built easy to set up and it is possible to
set up in any scenario - It has no requirement for DOM
- It has no dependency on any other Javascript
framework - It helps to write tests in easy steps because it
comes with clean syntax
3What is lightning Test Services?
Salesforce has come with a new concept Lightning
Test Services(LTS). LTS is a set of tools and
services - that create test suites for these
Lightning components. It helps in the validation
of the client-side behaviour of these components.
4You can install LTS in your Salesforce org in the
following two ways
- As an unmanaged package
- Install LTS by using a command in Salesforce
Developer Experience(SFDX)
5Steps to follow for installing Jasmine
We need to follow the following steps for
installing Jasmine and use it for further testing
the Lightning components 1. Installation of
Jasmine with the above SFDX command sfdx
forcelightningtestinstall
62. Once the installation is completed, you can
start to navigate in your browser - so as to open
the Jasmine test runner page. sfdx
forceorgopen -p /c/jasmineTests.app 3. Next,
Lightning component is to be used by Lightning
Test Service (LTS).
74. Now we need to create a Javascript file
containing Jasmine test method and upload it as a
static resource. 5. This static resource then
gets uploaded in Salesforce named as
JasmineTestDatatable. The reference to this app
has to be added to the static resource in
JasmineTests.app.
86. Finally, the Jasmine Test Runner is opened
with the following URL. https//ltYourDomaingt.light
ning.force.com/c/jasmineTests.app. This will show
the output of the testing in the form of which
test passed and which of the tests failed. It
also displays the pass and fail percentages.
97. Also the SFDX commands can be used to create a
Lightning test with a basic template, by using
the following commands Sfdxforcelightningtest
create
10Thank You