-
-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Coverage Overwritten after each testsuite #20
Comments
Maybe you can use beforeAll and afterAll |
Every Page instance would generate a new Ref: puppeteer-to-istanbul/index.js Line 4 in c57bd74
Update puppeteer-to-istanbul/lib/puppeteer-to-istanbul.js Lines 35 to 45 in de9109c
Besides puppeteer-to-istanbul/lib/output-files.js Lines 62 to 66 in de9109c
And, should not save file as ${parsedPath}-${this.iterator}.js if it is inline.
Update |
Was this ever resolved or did anyone find a workaround? I'm having the same issue where I can't find a way to keep all my results from multiple test suites. Do we just have to write all E2E tests in a single suite to get coverage with puppeteer-to-istanbul? |
@sebnitu Hi, what's the version you had used? And, would you mind give us a repo for producing this issue? BTW, make sure that you didn't forget
|
@joe223 Thanks for the reply! You can see this issue in my branch here: https://github.com/sebnitu/scroll-stash/tree/add-coverage-to-puppeteer This script should reproduce the issue: When I install using I currently have 4 integration test suites and depending on which one finishes last, I get that suites coverage results. This is consistent when I run each file individually and the result doesn't change when they're ran together. Current implementationEach suite has the following setup: beforeAll(async () => {
await page.coverage.startJSCoverage();
// other stuff..
});
afterAll(async () => {
const jsCoverage = await page.coverage.stopJSCoverage();
pti.write(jsCoverage);
}); |
I guess you should create an independent Page instance to collect coverage data. @sebnitu eg: describe('Wheel Action', () => {
let page = null
before(async function () {
page = await browser.newPage()
await page.coverage.startJSCoverage()
await page.goto(global.entryPath)
})
after(async function () {
const [jsCoverage] = await Promise.all([
page.coverage.stopJSCoverage()
])
pti.write([...jsCoverage])
})
// balabala |
@joe223 @sebnitu The "problem" is in https://github.com/istanbuljs/puppeteer-to-istanbul/blob/master/lib/puppeteer-to-istanbul.js, line 29: fs.writeFileSync(outFilePath, '') |
@sebnitu To merge coverage information from different test suites, you can do this:
|
My suggestion with passing outputName was probably based on a forked version I was working on. Basically I created my own option for PuppeteerToIstanbul, to override the out.json file name, much like it's done for the storagePath, "./.ny_output". Maybe I'll open a pull request for it. |
Every time you open a new page, the coverage gets overwritten. If you keep all the testings on the same page then this wouldn't be a problem. For example, open new page and start coverage in your first describe block's beforeAll function. Then, close page and end coverage in your last describe block's afterAll function. If you need to reset your page in each describe, you could do a refresh page instead of opening a new page that erases previous coverage. |
Hello!
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();
});`
Please let me know if there is any more information that you need. Thank you for your time, speak to you soon hopefully!
The text was updated successfully, but these errors were encountered: