mxschmitt / playwright-test-coverage

Playwright Test (@playwright/test) demo to collect coverage information via Istanbul
MIT License
108 stars 16 forks source link

Include iframes in coverage report #12

Open echenley opened 2 years ago

echenley commented 2 years ago

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__))
    );
  }
}