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

Add test coverage #1818

Merged
merged 3 commits into from
Aug 21, 2023
Merged

Add test coverage #1818

merged 3 commits into from
Aug 21, 2023

Conversation

Fil
Copy link
Contributor

@Fil Fil commented Aug 21, 2023

nyc doesn't support ESM, but c8 does!

I'm not building this by default on test:mocha because it slows things down quite a bit (down to 32s from 24s) ((and tests are already too slow)).

So you need to run yarn test:coverage to run this. It outputs the following text report (in color):

----------------------|---------|----------|---------|---------|-----------------------------------------------------------------------------------------------------------------
File                  | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------------------|---------|----------|---------|---------|-----------------------------------------------------------------------------------------------------------------
All files             |   95.54 |    89.37 |   92.78 |   95.54 |
 src                  |   97.12 |    91.47 |   96.54 |   97.12 |
  axes.js             |     100 |      100 |     100 |     100 |
  channel.js          |   97.28 |    89.18 |     100 |   97.28 | 70,72-73,157,168
  context.js          |     100 |       80 |     100 |     100 | 5
  curve.js            |   89.18 |       75 |     100 |   89.18 | 52-59
  defined.js          |     100 |      100 |     100 |     100 |
  dimensions.js       |   99.32 |    87.27 |     100 |   99.32 | 144
  facet.js            |   97.97 |    95.79 |     100 |   97.97 | 110,177-178,187
  format.js           |     100 |      100 |     100 |     100 |
  index.js            |     100 |      100 |     100 |     100 |
  legends.js          |   98.76 |    81.57 |     100 |   98.76 | 55
  mark.js             |   98.19 |    87.14 |     100 |   98.19 | 63,82-83
  marker.js           |   87.71 |       90 |    90.9 |   87.71 | 15,26,28,70-80
  math.js             |     100 |      100 |     100 |     100 |
  memoize.js          |     100 |      100 |     100 |     100 |
  options.js          |   96.12 |    93.17 |   94.11 |   96.12 | 186-187,192-194,221-222,525-538
  plot.js             |   99.86 |    94.82 |   97.05 |   99.86 | 669
  projection.js       |   96.86 |    85.56 |      96 |   96.86 | 97-98,124,128,134,144,146,148,159
  scales.js           |    94.7 |    96.21 |    90.9 |    94.7 | 264-269,272-277,280-285,315-316,371,375-377,449,470-471,502-504
  stats.js            |   93.98 |    53.33 |     100 |   93.98 | 32-39
  style.js            |   99.12 |     91.6 |     100 |   99.12 | 247-250
  symbol.js           |   98.41 |    73.33 |     100 |   98.41 | 53
  template.js         |     100 |      100 |     100 |     100 |
  time.js             |   95.09 |       84 |     100 |   95.09 | 78-80,82-84,139,150
  warnings.js         |     100 |      100 |     100 |     100 |
 src/interactions     |    67.8 |    89.13 |   63.63 |    67.8 |
  pointer.js          |    67.8 |    89.13 |   63.63 |    67.8 | 80-99,109-124,138-157,160-166,169-171
 src/legends          |     100 |    93.58 |      90 |     100 |
  ramp.js             |     100 |    94.87 |   83.33 |     100 | 62,116
  swatches.js         |     100 |     92.3 |     100 |     100 | 12,165-166
 src/marks            |   95.92 |    89.56 |   94.78 |   95.92 |
  area.js             |     100 |      100 |     100 |     100 |
  arrow.js            |   95.54 |    82.85 |     100 |   95.54 | 123-129,163,167
  auto.js             |   98.67 |       88 |     100 |   98.67 | 101,145,162,175-176
  axis.js             |   99.56 |    90.73 |   97.29 |   99.56 | 439-441
  bar.js              |     100 |    95.23 |     100 |     100 | 87,92
  bollinger.js        |   64.28 |       75 |      75 |   64.28 | 19-48
  box.js              |      75 |      100 |   85.71 |      75 | 39-59
  cell.js             |     100 |      100 |     100 |     100 |
  contour.js          |     100 |     90.9 |     100 |     100 | 29,53,153,196,209
  crosshair.js        |   98.16 |      100 |   88.88 |   98.16 | 17-18
  delaunay.js         |   96.06 |    89.47 |     100 |   96.06 | 133-138,255-260
  density.js          |     100 |    84.61 |     100 |     100 | 30,43,84,107-110,152,165,173
  dot.js              |     100 |    91.93 |     100 |     100 | 61,72,95-96
  frame.js            |     100 |      100 |     100 |     100 |
  geo.js              |   97.93 |    83.33 |   77.77 |   97.93 | 75-76
  hexgrid.js          |     100 |      100 |     100 |     100 |
  image.js            |   97.74 |    84.28 |     100 |   97.74 | 124-126
  line.js             |   96.46 |       90 |     100 |   96.46 | 49-50,92-93
  linearRegression.js |   88.43 |    90.62 |   69.23 |   88.43 | 85-86,88-96,98-101,126-130
  link.js             |   97.29 |     82.6 |     100 |   97.29 | 101,108-109
  raster.js           |    99.6 |    92.14 |     100 |    99.6 | 259,267
  rect.js             |     100 |    97.29 |     100 |     100 | 101
  rule.js             |   98.58 |       88 |     100 |   98.58 | 138-139
  text.js             |     100 |    96.98 |     100 |     100 | 88,137,282-285,419
  tick.js             |     100 |      100 |     100 |     100 |
  tip.js              |   71.59 |    61.03 |   53.84 |   71.59 | 138,140,197-200,205-208,220-244,265-271,273-294,296-319,331-335,337-341
  tree.js             |     100 |     64.7 |     100 |     100 | 39,48-78,87
  vector.js           |      97 |    94.59 |     100 |      97 | 61-63,113-114
 src/scales           |   98.77 |    90.66 |    92.3 |   98.77 |
  diverging.js        |   93.93 |    88.57 |   68.75 |   93.93 | 56-57,139-140,148,151-152,159,162-163
  index.js            |     100 |      100 |     100 |     100 |
  ordinal.js          |   99.23 |    95.16 |     100 |   99.23 | 116
  quantitative.js     |   99.69 |    87.41 |     100 |   99.69 | 315
  schemes.js          |     100 |    93.87 |     100 |     100 | 186,203,265
  temporal.js         |     100 |      100 |     100 |     100 |
 src/transforms       |   92.73 |    85.16 |   86.99 |   92.73 |
  basic.js            |   86.42 |    81.94 |   86.66 |   86.42 | 63-64,102-107,116-126
  bin.js              |   92.42 |    88.63 |   81.81 |   92.42 | 275-276,281-282,309,311,313,315,343,345,347,349,351,353,423-434,449-450,455-456,461-462,467-468,473-474
  centroid.js         |     100 |      100 |     100 |     100 |
  dodge.js            |   95.86 |    89.39 |   86.66 |   95.86 | 26-27,32,42-43,51
  group.js            |   96.47 |    84.56 |   90.24 |   96.47 | 248,266,283-285,307-310,362-364,371-372
  hexbin.js           |     100 |    86.66 |     100 |     100 | 36-45,53,72-73,75,88
  identity.js         |     100 |      100 |     100 |     100 |
  inset.js            |     100 |    88.88 |     100 |     100 | 17
  interval.js         |     100 |    88.09 |     100 |     100 | 9,36-37,56-58
  map.js              |   93.33 |       76 |   88.88 |   93.33 | 58,62,65-68
  normalize.js        |   98.95 |    81.81 |     100 |   98.95 | 40
  select.js           |   83.49 |       80 |   69.23 |   83.49 | 9-15,39,43-44,55-56,59-60,66-68
  stack.js            |   89.82 |    90.15 |   81.48 |   89.82 | 16-20,37-41,134,242,244,248,250-251,254,263-265,268-276,320-325
  tree.js             |   88.92 |    66.66 |      76 |   88.92 | 130,132,148-150,157,161-163,165-167,206,208,210,220,222,224,226,228,230,234,236,238,240,251-253,255-257,267-269
  window.js           |   91.16 |    90.44 |   94.28 |   91.16 | 21-23,37,40-50,57,71,94-104
----------------------|---------|----------|---------|---------|-----------------------------------------------------------------------------------------------------------------

It also outputs coverage/lcov.info which we can use for example with the coverage-gutters extension in VSCode.

I was pleasantly surprised by our current coverage. Many of the missing lines are the ones that throw an error on invalid options.

Some thoughts/questions:

  • do we need c8 as a dev dependency (I could use npx instead)
  • does it make sense to activate it in CI (suggestion: comment on the coverage of checked-in files in each PR)
  • I'd like to find a way to activate coverage analysis test by test, to output a matrix of (test, feature)
  • do we need to clean up in prepublish?

@Fil Fil requested a review from mbostock August 21, 2023 07:32
@Fil Fil enabled auto-merge (squash) August 21, 2023 17:52
@Fil Fil merged commit a24e805 into main Aug 21, 2023
1 check passed
@Fil Fil deleted the fil/c8 branch August 21, 2023 18:04
@Fil Fil mentioned this pull request Aug 23, 2023
chaichontat pushed a commit to chaichontat/plot that referenced this pull request Jan 14, 2024
* test coverage with c8

* use npx for c8

---------

Co-authored-by: Mike Bostock <[email protected]>
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