Skip to content

Commit 459f31f

Browse files
committed
Make cssCoverage fixture auto so it runs for every test
1 parent c411bc6 commit 459f31f

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

‎README.md‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,28 +88,22 @@ export const test = base.extend({
8888
await fs.writeFile(file_path, JSON.stringify(coverage))
8989
await testInfo.attach('css-coverage', { path: file_path, contentType: 'application/json' })
9090
},
91-
{},
91+
{ auto: true },
9292
],
9393
})
9494
export { expect }
9595
```
9696

97-
Use `cssCoverage` in any test where you want to collect coverage:
97+
Import `test` from your fixtures file instead of `@playwright/test` and coverage is collected automatically for every test:
9898

9999
```ts
100100
import { test, expect } from './fixtures.js'
101101

102-
test('my test', async ({ page, cssCoverage }) => {
102+
test('my test', async ({ page }) => {
103103
await page.goto('https://example.com')
104104
})
105105
```
106106

107-
Or enable it for an entire file with a single line:
108-
109-
```ts
110-
test.beforeEach(async ({ cssCoverage }) => {})
111-
```
112-
113107
Pass the output directory to the `css-coverage` CLI to analyze results:
114108

115109
```sh

0 commit comments

Comments
 (0)