Testing ensures your code functions as you intend and saves you from tedious debugging.
See the Starter Kits documentation for an easy to use setup with a fully pre-configured testing environment that works great for testing Lit components.
Selecting a test frameworkPermalink to “Selecting a test framework”
There are a few things you'll want to make sure your testing environment supports to effectively test your Lit code.
Testing in the browserPermalink to “Testing in the browser”
Lit components are designed to run in the browser so testing should be conducted in a browser environment. Tools specifically focusing on testing node code may not be a good fit.
Using polyfillsPermalink to “Using polyfills”
To test on older browsers, your test environment will need to load some polyfills, including the web components polyfills and Lit's
polyfill-support module. See the Polyfills documentation for more details.
Using Web Test RunnerPermalink to “Using Web Test Runner”
We recommend using Web Test Runner since it is specifically designed to test modern web libraries like Lit using modern web features like custom elements and shadow DOM. See the Getting Started documentation for Web Test Runner.
In order to support older browsers, you need to configure Web Test Runner as follows: