Skip to content

Commit cc0bf9e

Browse files
committed
Add comments to README fixture explaining each step
1 parent 459f31f commit cc0bf9e

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎README.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,17 @@ import * as path from 'node:path'
6868
export const test = base.extend({
6969
cssCoverage: [
7070
async ({ page }, use, testInfo) => {
71+
// Start collecting CSS coverage before the test runs
7172
await page.coverage.startCSSCoverage()
73+
74+
// Run the test
7275
await use()
76+
77+
// Collect the coverage data after the test finishes
7378
let coverage = await page.coverage.stopCSSCoverage()
7479

80+
// Build a unique, human-readable filename from the test's title path,
81+
// replacing characters that are invalid or ambiguous in file names
7582
let file_name =
7683
testInfo.titlePath
7784
.map((s) =>
@@ -82,12 +89,17 @@ export const test = base.extend({
8289
)
8390
.join('-') + '.json'
8491

92+
// Write the coverage data to disk
8593
let dir = path.join(process.cwd(), 'css-coverage')
8694
await fs.mkdir(dir, { recursive: true })
8795
let file_path = path.join(dir, file_name)
8896
await fs.writeFile(file_path, JSON.stringify(coverage))
97+
98+
// Attach the file to the Playwright HTML report for easy inspection
8999
await testInfo.attach('css-coverage', { path: file_path, contentType: 'application/json' })
90100
},
101+
// auto: true makes this fixture run for every test without needing
102+
// to explicitly request it as a parameter
91103
{ auto: true },
92104
],
93105
})

0 commit comments

Comments
 (0)