Workflow to Test Your Components with Lightning Web Security
To evaluate how your custom Lightning components run with Lightning Web Security (LWS) enabled, follow this workflow.
You can’t disable LWS on individual components. If you refactor components to take advantage of features only available with LWS enabled, ensure that you thoroughly test all your components in sandboxes before you push them to production orgs. See Considerations Before Using LWS-Only Features.
-
Download and configure the ESLint rules as described in Install ESLint Rules for Lightning Web Security.
-
Run the base rule set against your components as described in Run Base Rules Against Your Project.
-
Fix any errors revealed by the base ESLint rules.
-
As you fix the errors, try the revised code in the Lightning Web Security Console to see if it can run with LWS.
-
If your code is affected by distortions, review the distortion descriptions in the LWS Distortion Viewer for help with understanding the issues.
-
After you fix the linting errors, enable Use Lightning Web Security for Lightning web components and Aura components in a sandbox, as described in Enable Lightning Web Security in an Org.
-
Deploy your components to the sandbox.
-
Test your components manually and by running your automated tests.
-
If you notice any abnormal behavior or test results, try running the
recommended
rule set on your component code to debug any additional issues. You can skip this step if you ran the code in Lightning Web Security Console. The tool runs both sets of ESLint rules. -
If your component isn’t performing correctly with Lightning Web Security enabled, or you can’t fix the ESLint errors, you can discuss the issue in the Lightning Components Development group on Trailhead.
-
If wish to keep your components backwards compatible with Lightning Locker, follow these additional steps. For backwards compatibility with Lightning Locker, your components can't use features only available with LWS enabled.
- In the sandbox, Disable the Use Lightning Web Security for Lightning web components and Aura components setting.
- To ensure that the correct files are loaded in the browser for Lightning Locker, clear the browser cache. If the results aren’t what you expect after clearing the cache, try the other cache-related solutions in Delayed Enabling or Disabling of LWS.
- To evaluate whether your components still work with Lightning Locker, test the modified components in the sandbox org. Use the Lightning Locker Console and the Locker API Viewer tools.
-
If the modified components perform well and pass tests in the sandbox, deploy the changes to production.
-
Enable the Use Lightning Web Security for Lightning web components and Aura components setting in production.
See Also