You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/lit-dev-content/site/docs/v3/tools/testing.md
+48-2Lines changed: 48 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ See the [Starter Kits](/docs/v3/tools/starter-kits/) documentation for an easy t
15
15
16
16
## Selecting a test framework
17
17
18
-
Lit is a standard modern Javascript library, and you can use virtually any Javascript testing framework to test your Lit code. There are many popular options, including [Jest](https://jestjs.io/), [Karma](https://karma-runner.github.io/), [Mocha](https://mochajs.org/), [Jasmine](https://jasmine.github.io/), and [Web Test Runner](https://modern-web.dev/docs/test-runner/overview/).
18
+
Lit is a standard modern Javascript library, and you can use virtually any Javascript testing framework to test your Lit code. There are many popular options, including [Jest](https://jestjs.io/), [Karma](https://karma-runner.github.io/), [Mocha](https://mochajs.org/), [Jasmine](https://jasmine.github.io/), [WebdriverIO](https://webdriver.io)and [Web Test Runner](https://modern-web.dev/docs/test-runner/overview/).
19
19
20
20
There are a few things you'll want to make sure your testing environment supports to effectively test your Lit code.
21
21
@@ -37,7 +37,7 @@ To test on older browsers, your test environment will need to load some polyfill
37
37
38
38
## Using Web Test Runner { #web-test-runner }
39
39
40
-
We recommend using [Web Test Runner](https://modern-web.dev/docs/test-runner/overview/) 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](https://modern-web.dev/guides/test-runner/getting-started) documentation for Web Test Runner.
40
+
[Web Test Runner](https://modern-web.dev/docs/test-runner/overview/) is specifically designed to test modern web libraries like Lit using modern web features like custom elements and shadow DOM. See the [Getting Started](https://modern-web.dev/guides/test-runner/getting-started) documentation for Web Test Runner.
41
41
42
42
In order to support older browsers, you need to configure Web Test Runner as follows:
43
43
@@ -75,3 +75,49 @@ export default {
75
75
};
76
76
```
77
77
78
+
## Using WebdriverIO
79
+
80
+
[WebdriverIO](https://webdriver.io) is a good option for your component or end-to-end tests. It has very compelling advantages like support for [mocking](https://webdriver.io/docs/component-testing/mocking) and [code coverage](https://webdriver.io/docs/component-testing/coverage) reporting.
81
+
82
+
You can set up WebdriverIO in your project via:
83
+
84
+
```bash
85
+
npm init wdio@latest ./
86
+
```
87
+
88
+
It will start a configuration wizard that will guide you through some questions. Make sure select the following:
89
+
90
+
-__What type of testing would you like to do?__<br>Component or Unit Testing - in the browser
91
+
-__Which framework do you use for building components?__<br>Lit
92
+
93
+
The remaining questions can be answered as desired.
94
+
95
+
In order test the component you have to render it into the test page before the test starts and ensure it gets cleaned up afterwards:
96
+
97
+
```ts
98
+
import { expect, $ } from'@wdio/globals'
99
+
100
+
// Component.ts contains the <simple-greeting> component implemented the same as:
Find more information on [element assertions](https://webdriver.io/docs/api/expect-webdriverio), [finding elements](https://webdriver.io/docs/selectors#deep-selectors) within the Shadow DOM and [more](https://webdriver.io/docs/component-testing) in the WebdriverIO documentation.
0 commit comments