Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
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.

README.md 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. # babel-plugin-istanbul
  2. [![Greenkeeper badge](https://badges.greenkeeper.io/istanbuljs/babel-plugin-istanbul.svg)](https://greenkeeper.io/)
  3. [![Build Status](https://travis-ci.org/istanbuljs/babel-plugin-istanbul.svg?branch=master)](https://travis-ci.org/istanbuljs/babel-plugin-istanbul)
  4. [![Coverage Status](https://coveralls.io/repos/github/istanbuljs/babel-plugin-istanbul/badge.svg?branch=master)](https://coveralls.io/github/istanbuljs/babel-plugin-istanbul?branch=master)
  5. [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
  6. [![community slack](http://devtoolscommunity.herokuapp.com/badge.svg)](http://devtoolscommunity.herokuapp.com)
  7. _Having problems? want to contribute? join our [community slack](http://devtoolscommunity.herokuapp.com)_.
  8. A Babel plugin that instruments your code with Istanbul coverage.
  9. It can instantly be used with [karma-coverage](https://github.com/karma-runner/karma-coverage) and mocha on Node.js (through [nyc](https://github.com/bcoe/nyc)).
  10. __Note:__ This plugin does not generate any report or save any data to any file;
  11. it only adds instrumenting code to your JavaScript source code.
  12. To integrate with testing tools, please see the [Integrations](#integrations) section.
  13. ## Usage
  14. Install it:
  15. ```
  16. npm install --save-dev babel-plugin-istanbul
  17. ```
  18. Add it to `.babelrc` in test mode:
  19. ```js
  20. {
  21. "env": {
  22. "test": {
  23. "plugins": [ "istanbul" ]
  24. }
  25. }
  26. }
  27. ```
  28. Optionally, use [cross-env](https://www.npmjs.com/package/cross-env) to set
  29. `NODE_ENV=test`:
  30. ```json
  31. {
  32. "scripts": {
  33. "test": "cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text mocha test/*.js"
  34. }
  35. }
  36. ```
  37. ## Integrations
  38. ### karma
  39. It _just works_ with Karma. First, make sure that the code is already transpiled by Babel (either using `karma-babel-preprocessor`, `karma-webpack`, or `karma-browserify`). Then, simply set up [karma-coverage](https://github.com/karma-runner/karma-coverage) according to the docs, but __don’t add the `coverage` preprocessor.__ This plugin has already instrumented your code, and Karma should pick it up automatically.
  40. It has been tested with [bemusic/bemuse](https://codecov.io/github/bemusic/bemuse) project, which contains ~2400 statements.
  41. ### mocha on node.js (through nyc)
  42. Configure Mocha to transpile JavaScript code using Babel, then you can run your tests with [`nyc`](https://github.com/bcoe/nyc), which will collect all the coverage report.
  43. babel-plugin-istanbul respects the `include`/`exclude` configuration options from nyc,
  44. but you also need to __configure NYC not to instrument your code__ by adding these settings in your `package.json`:
  45. ```js
  46. "nyc": {
  47. "sourceMap": false,
  48. "instrument": false
  49. },
  50. ```
  51. ## Ignoring files
  52. You don't want to cover your test files as this will skew your coverage results. You can configure this by providing plugin options matching nyc's [`exclude`/`include` rules](https://github.com/bcoe/nyc#excluding-files):
  53. ```json
  54. {
  55. "env": {
  56. "test": {
  57. "plugins": [
  58. ["istanbul", {
  59. "exclude": [
  60. "**/*.spec.js"
  61. ]
  62. }]
  63. ]
  64. }
  65. }
  66. }
  67. ```
  68. If you don't provide options in your Babel config, the plugin will look for `exclude`/`include` config under an `"nyc"` key in `package.json`.
  69. You can also use [istanbul's ignore hints](https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes) to specify specific lines of code to skip instrumenting.
  70. ## Source Maps
  71. By default, this plugin will pick up inline source maps and attach them to the instrumented code such that code coverage can be remapped back to the original source, even for multi-step build processes. This can be memory intensive. Set `useInlineSourceMaps` to prevent this behavior.
  72. ```json
  73. {
  74. "env": {
  75. "test": {
  76. "plugins": [
  77. ["istanbul", {
  78. "useInlineSourceMaps": false
  79. }]
  80. ]
  81. }
  82. }
  83. }
  84. ```
  85. If you're instrumenting code programatically, you can pass a source map explicitly.
  86. ```js
  87. import babelPluginIstanbul from 'babel-plugin-istanbul';
  88. function instrument(sourceCode, sourceMap, fileName) {
  89. return babel.transform(sourceCode, {
  90. filename,
  91. plugins: [
  92. [babelPluginIstanbul, {
  93. inputSourceMap: sourceMap
  94. }]
  95. ]
  96. })
  97. }
  98. ```
  99. ## Credit where credit is due
  100. The approach used in `babel-plugin-istanbul` was inspired by [Thai Pangsakulyanont](https://github.com/dtinth)'s original library [`babel-plugin-__coverage__`](https://github.com/dtinth/babel-plugin-__coverage__).
  101. ## `babel-plugin-istanbul` for enterprise
  102. Available as part of the Tidelift Subscription.
  103. The maintainers of `babel-plugin-istanbul` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-babel-plugin-istanbul?utm_source=npm-babel-plugin-istanbul&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)