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.

  1. Download and configure the ESLint rules as described in Install ESLint Rules for Lightning Web Security.

  2. Run the base rule set against your components as described in Run Base Rules Against Your Project.

  3. Fix any errors revealed by the base ESLint rules.

  4. As you fix the errors, try the revised code in the Lightning Web Security Console to see if it can run with LWS.

  5. If your code is affected by distortions, review the distortion descriptions in the LWS Distortion Viewer for help with understanding the issues.

  6. 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.

  7. Deploy your components to the sandbox.

  8. Test your components manually and by running your automated tests.

  9. 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.

  10. 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.

  11. 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.

    1. In the sandbox, Disable the Use Lightning Web Security for Lightning web components and Aura components setting.
    2. 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.
    3. 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.
  12. If the modified components perform well and pass tests in the sandbox, deploy the changes to production.

  13. Enable the Use Lightning Web Security for Lightning web components and Aura components setting in production.

See Also