question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Generate (test) coverage statistics

See original GitHub issue

To identify parts of our code that are not covered by tests, or dead code in practice, generating coverage reports would be helpful. Another use case is to quickly identify which parts of PDF.js are relevant when analysing an issue in a specific PDF file (this can especially be useful to new contributors).

There are multiple tools, but I have had a good experience with https://github.com/gotwarlost/istanbul. It can be integrated with Travis, and the results can be published to an external service such as coveralls, see e.g. https://coveralls.io/github/Rob--W/cors-anywhere?branch=master (integrated with https://github.com/Rob--W/cors-anywhere/commit/f9af03e76249b4dd38722b459293773ccddb6c7d).

PDF.js has different ways of execution that I know of (see gulpfile.js for more details):

  • unittestcli - Runs some unit tests of PDF.js in Node.js (with minimal source changes, only with transpilation with babel, configured in gulpfile.js).
  • unittest - Runs some unit tests of PDF.js in the browser (with minimal source changes, only with transpilation by babel, configured in systemjs.config.js)
  • browsertest - Runs tests in browsers (we test Chrome and Firefox). This relies on the binary created by the generic build target, which uses code transpiled with babel and then bundled with webpack (configured in gulpfile.js).
  • examples/node/pdf2svg.js - Can be used to trigger the SVG rendering backend on Node.js (depends on the generic build target, just like browsertest)
  • as a browser extension (Firefox / Chromium), using the firefox / chromium build targets (uses a similar build process as the generic target, just with different DEFINES)

Ideally we would obtain coverage statistics for the original sources, but to start with we could also settle for coverage statistics on the generated JS files that directly run in the browser / Node.js (if it is easier).

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:3
  • Comments:44 (30 by maintainers)

github_iconTop GitHub Comments

1reaction
timvandermeijcommented, Jan 29, 2020

I don’t think anyone is working on this, so go ahead! It’s important to keep it simple for the initial patch. Since we use Gulp as our main tooling, it’s preferred to use that, but we’re also open for other suggestions. Refer to https://github.com/mozilla/pdf.js/issues/8632#issuecomment-455868037 for implementation ideas. It doesn’t require much experience with Gulp though because Gulp is a fairly simple task runner, i.e., it mostly wraps anything you would also do in an NPM script. Take a look at the Gulpfile to get some inspiration.

1reaction
timvandermeijcommented, Nov 12, 2019

Yes, feel free to work on this! We should start simple; see https://github.com/mozilla/pdf.js/issues/8632#issuecomment-455868037 for a possible approach.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating Test Coverage Reports - Oracle Help Center
Step 2 of 2: Generate Report, Press Enter to expand · Select one or more tests in the Select Test(s) for the Test...
Read more >
Test Coverage in Software Testing - Guru99
Formula to calculate Test Coverage ; Step 1) The total lines of code in the piece of software quality you are testing ;...
Read more >
Test coverage visualization - GitLab Docs
With the help of GitLab CI/CD, you can collect the test coverage information of your favorite testing or coverage-analysis tool, and visualize this ......
Read more >
Code coverage testing - Visual Studio (Windows)
The Code Coverage Results window usually shows the result of the most recent run. The results will vary if you change your test...
Read more >
Test coverage overview - SonarQube Documentation
Test coverage reports and test execution reports are important metrics in assessing the quality of your code. Test coverage reports tell you what...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found