web 3d图形渲染器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
2.1 KiB

  1. # v8-to-istanbul
  2. [![Build Status](https://travis-ci.org/istanbuljs/v8-to-istanbul.svg?branch=master)](https://travis-ci.org/istanbuljs/v8-to-istanbul)
  3. [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
  4. ![nycrc config on GitHub](https://img.shields.io/nycrc/istanbuljs/v8-to-istanbul)
  5. converts from v8 coverage format to [istanbul's coverage format](https://github.com/gotwarlost/istanbul/blob/master/coverage.json.md).
  6. ## Usage
  7. ```js
  8. const v8toIstanbul = require('v8-to-istanbul')
  9. // the path to the original source-file is required, as its contents are
  10. // used during the conversion algorithm.
  11. const converter = v8toIstanbul('./path-to-instrumented-file.js')
  12. await converter.load() // this is required due to the async source-map dependency.
  13. // provide an array of coverage information in v8 format.
  14. converter.applyCoverage([
  15. {
  16. "functionName": "",
  17. "ranges": [
  18. {
  19. "startOffset": 0,
  20. "endOffset": 520,
  21. "count": 1
  22. }
  23. ],
  24. "isBlockCoverage": true
  25. },
  26. // ...
  27. ])
  28. // output coverage information in a form that can
  29. // be consumed by Istanbul.
  30. console.info(JSON.stringify(converter.toIstanbul()))
  31. ```
  32. ## Ignoring Uncovered Lines
  33. Sometimes you might find yourself wanting to ignore uncovered lines
  34. in your application (for example, perhaps you run your tests in Linux, but
  35. there's code that only executes on Windows).
  36. To ignore lines, use the special comment `/* c8 ignore next */`.
  37. ### ignoring the next line
  38. ```js
  39. const myVariable = 99
  40. /* c8 ignore next */
  41. if (process.platform === 'win32') console.info('hello world')
  42. ```
  43. ### ignoring the next N lines
  44. ```js
  45. const myVariable = 99
  46. /* c8 ignore next 3 */
  47. if (process.platform === 'win32') {
  48. console.info('hello world')
  49. }
  50. ```
  51. ### ignoring all lines until told
  52. ```js
  53. /* c8 ignore start */
  54. function dontMindMe() {
  55. // ...
  56. }
  57. /* c8 ignore stop */
  58. ```
  59. ### ignoring the same line as the comment
  60. ```js
  61. const myVariable = 99
  62. const os = process.platform === 'darwin' ? 'OSXy' /* c8 ignore next */ : 'Windowsy'
  63. ```
  64. ## Testing
  65. To execute tests, simply run:
  66. ```bash
  67. npm test
  68. ```