Skip to content
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

chore: configure jest coverage #1222

Merged
merged 4 commits into from
Jan 11, 2021
Merged

chore: configure jest coverage #1222

merged 4 commits into from
Jan 11, 2021

Conversation

djskinner
Copy link
Contributor

Goal

To monitor code coverage and ensure high / increasing code quality.

Design

This is a fairly standard approach to generating code coverage reports with jest. jest supports many Istanbul reporters which are compatible with a range of viewers and CI setups.

This setup also includes files that do not have corresponding test files so provides a more accurate picture of the actual coverage of source.

This will also support (with additional work) danger bot to add code coverage comments on PRs.

Changeset

  • Jest configuration to get code coverage working
  • Some tests were pointing to the package root, meaning the package.json main property was being used to resolve the import. This lead to tests being run on the dist/ output. Whilst testing on the final output has its merits it is more common to test against the source. If we run the tests against the dist/ output the coverage for the source file will be reported as zero.
  • As a consequence of the above co-located TypeScript declaration files need to be created whereas previously they were able to be resolved using the package.json types field.

Testing

automated build and tests passing

@github-actions
Copy link

github-actions bot commented Jan 5, 2021

@bugsnag/browser bundle size diff

Minified Minfied + Gzipped
Before 40.70 kB 12.54 kB
After 40.70 kB 12.54 kB
± No change No change

Generated by 🚫 dangerJS against 1fdd291

* next:
  Bump Maze Runner version for local running
  test(bugsnag-integrity): enforce integrity header for Expo
@@ -1,5 +1,4 @@
import BugsnagBrowserStatic from '..'
import { Breadcrumb, Session } from '../types/bugsnag'
import BugsnagBrowserStatic, { Breadcrumb, Session } from '../src/notifier'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to test against src rather than dist or coverage doesn't report correctly. As a consequence we lose the types, hence the colocated definitions file above that re-exports the types.

@@ -1,22 +0,0 @@
/* global jest */
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be unused

@@ -27,11 +41,12 @@ module.exports = {
'plugin-window-onerror',
'plugin-strip-query-string',
'plugin-interaction-breadcrumbs',
'plugin-inline-script-content',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This oversight was picked up by the coverage report

@djskinner djskinner marked this pull request as ready for review January 6, 2021 14:57
@bengourley bengourley merged commit a7e72dc into next Jan 11, 2021
@bengourley bengourley deleted the jest-coverage branch January 11, 2021 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants