playwright-test-coverage icon indicating copy to clipboard operation
playwright-test-coverage copied to clipboard

Include iframes in coverage report

Open echenley opened this issue 3 years ago • 0 comments

This isn't an issue per-se, but in case anyone needs to include all iframes in their coverage numbers, you can modify the context script as follows:

for (const page of context.pages()) {
  await page.evaluate(() =>
    (window as any).collectIstanbulCoverage(JSON.stringify((window as any).__coverage__))
  );

  for (const frame of context.frames()) {
    await frame.evaluate(() => 
      (window as any).collectIstanbulCoverage(JSON.stringify((window as any).__coverage__))
    );
  }
}

echenley avatar Aug 10 '22 16:08 echenley