Coverage Overwritten after each testsuite
See original GitHub issueHello!
I have a StencilJS project (version 0.14.0) and they have started using Puppeteer, they have provided a small library to implement Puppeteer tests. I have implemented your dependency the way you have documented it. However if I do the same setup in each test file the previous coverage appears to get overwritten. This is reflected when I generate the nyc report. Here is my general setup for each test file.
`import { newE2EPage, E2EPage } from ‘@stencil/core/testing’; import * as pti from ‘puppeteer-to-istanbul’;
describe(‘my-component’, () => { let page: E2EPage;
beforeEach(async () => { page = await newE2EPage(); await page.coverage.startJSCoverage(); });
afterEach(async () => { const jsCoverage = await page.coverage.stopJSCoverage();
pti.write(jsCoverage);
});`
Please let me know if there is any more information that you need. Thank you for your time, speak to you soon hopefully!
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:10 (3 by maintainers)
Every Page instance would generate a new
puppeteerFormat
. How could we merge multiple puppeteerFormat data?Ref: https://github.com/istanbuljs/puppeteer-to-istanbul/blob/c57bd741534813a7b42c8f300ddb61ef42086ef1/index.js#L4
Update We should set
jsonPart
as a top scoped variable in puppeteer-to-istanbul, so every page instance test coverage record could be stored. https://github.com/istanbuljs/puppeteer-to-istanbul/blob/de9109c794523eb8924ef24770503908650cc952/lib/puppeteer-to-istanbul.js#L35-L45Besides
iterator
should be same asjsonPart
https://github.com/istanbuljs/puppeteer-to-istanbul/blob/de9109c794523eb8924ef24770503908650cc952/lib/output-files.js#L62-L66 And, should not save file as${parsedPath}-${this.iterator}.js
if it is inline.Update This is the fix PR https://github.com/istanbuljs/puppeteer-to-istanbul/pull/42
Maybe you can use beforeAll and afterAll