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
{{ message }}
This repository was archived by the owner on Sep 11, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+30-7Lines changed: 30 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -75,20 +75,19 @@ describe('What is my browser', () => {
75
75
You can specify a `jest-playwright.config.js` at the root of the project or define a custom path using the `JEST_PLAYWRIGHT_CONFIG` environment variable. It should export a config object.
76
76
77
77
-`launchOptions` <[object]> [All Playwright launch options](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsertypelaunchoptions) can be specified in config. Since it is JavaScript, you can use all stuff you need, including environment.
78
-
-`connectOptions` <[object]> [All Playwright connect options](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsertypeconnectoptions) can be specified in config.
79
-
-`contextOptions` <[object]> [All Playwright context options](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsernewcontextoptions) can be specified in config.
78
+
-`connectOptions` <[object]>.[All Playwright connect options](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsertypeconnectoptions) can be specified in config.
79
+
-`contextOptions` <[object]>.[All Playwright context options](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsernewcontextoptions) can be specified in config.
80
80
-`browsers` <[string[]]>. Define [browsers](https://github.com/microsoft/playwright/blob/master/docs/api.md#class-browsertype) to run tests in.
81
81
-`chromium` Each test runs Chromium (default).
82
82
-`firefox` Each test runs Firefox.
83
83
-`webkit` Each test runs Webkit.
84
84
-`devices` <[string[]]>. Define a [devices](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsertypedevices) to run tests in. Actual list of devices can be found [here](https://github.com/Microsoft/playwright/blob/master/src/deviceDescriptors.ts).
85
-
-`exitOnPageError` <[boolean]> Exits process on any page error. Defaults to `true`.
-`selectors` <[array]>. Define [selectors](https://github.com/microsoft/playwright/blob/v0.11.1/docs/api.md#class-selectors). Each selector must be an object with name and script properties.
88
89
89
-
Usage with [query-selector-shadow-dom](https://github.com/Georgegriff/query-selector-shadow-dom):
90
-
91
-
`jest-playwright.config.js`:
90
+
Usage with [query-selector-shadow-dom](https://github.com/Georgegriff/query-selector-shadow-dom) in `jest-playwright.config.js`:
92
91
93
92
```javascript
94
93
const {
@@ -127,6 +126,30 @@ Debugging tests can be hard sometimes and it is very useful to be able to pause
127
126
awaitjestPlaywright.debug()
128
127
```
129
128
129
+
## Tracking the coverage
130
+
131
+
It's possible to track the coverage of the end-to-end tests with the [babel-plugin-istanbul](https://github.com/istanbuljs/babel-plugin-istanbul) Babel plugin configured. It needs to be included in the web application which you are gonna test otherwise it won't work. To use it, you have to set `collectCoverage` in the `jest-playwright.config.js` to `true` and add the corresponding `saveCoverage(page)` call to your tests like that:
132
+
133
+
```js
134
+
afterEach(async () => {
135
+
awaitjestPlaywright.saveCoverage(page)
136
+
})
137
+
```
138
+
139
+
With this change, it will write the coverage data to the `.nyc_output/coverage.json` file which can be transformed using [`nyc`](https://github.com/istanbuljs/nyc#readme) to the lcov format:
140
+
141
+
```
142
+
npx nyc report --reporter=lcovonly
143
+
```
144
+
145
+
or to HTML:
146
+
147
+
```
148
+
npx nyc report --reporter=html
149
+
```
150
+
151
+
which will create a HTML website in the `coverage` directory.
152
+
130
153
## Start a server
131
154
132
155
Jest Playwright integrates a functionality to start a server when running your test suite, like [jest-puppeteer](https://github.com/smooth-code/jest-puppeteer/blob/master/README.md#start-a-server). It automatically closes the server when tests are done.
0 commit comments