<commit_before>gulp-jsx-coverage
=================

Enable coverage on .JSX or .coffee files.

[![npm version](https://img.shields.io/npm/v/gulp-jsx-coverage.svg)](https://www.npmjs.org/package/gulp-jsx-coverage) [![Dependency Status](https://david-dm.org/zordius/gulp-jsx-coverage.svg)](https://david-dm.org/zordius/gulp-jsx-coverage) [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE.txt)

**This is not a gulp plugin, it just a task creator to help you deal with istanbul instrumenter and collect coverage report in gulp**

**NOTE: coffee html/lcov report is buggy now**

Install
-------

```
npm install gulp-jsx-coverage
```

Usage
-----

* The golden rule: **Use .jsx as ext name**

```javascript
gulp.task('your_task_name', require('gulp-jsx-coverage').createTask({
    src: ['test/**/*.js', 'test/components/*.jsx'],  // will pass to gulp.src
    istanbul: {                                      // will pass to istanbul
        coverageVariable: '__MY_TEST_COVERAGE__',
        exclude: /node_modules|\/test\//             // pattern to skip instrument
    },
    coverage: {
        reporters: ['text-summary', 'json', 'lcov'],
        directory: 'coverage'                        // will pass to istanbul reporters
    },
    mocha: {                                         // will pass to mocha
        reporter: 'tap'
    },
    react: {                                         // will pass to react-tools
        sourceMap: true
    },
    coffee: {                                        // will pass to coffee.compile
        sourceMap: true
    }
}));
```

Live Example
------------

```sh
git clone https://github.com/zordius/gulp-jsx-coverage.git
cd gulp-jsx-coverage
npm install
npm test
```

Output:

```
> gulp-jsx-coverage@0.0.1 test /Users/zordius/gulp-jsx-coverage
> gulp

[17:21:00] Using gulpfile ~/gulp-jsx-coverage/gulpfile.js
[17:21:00] Starting 'default'...


  test coverage
    ✓ should covered 

  test coverage
    ✓ should covered 


  2 passing (32ms)

-------------------|-----------|-----------|-----------|-----------|
File               |   % Stmts |% Branches |   % Funcs |   % Lines |
-------------------|-----------|-----------|-----------|-----------|
   test/           |     96.55 |       100 |     91.67 |     96.55 |
      target.js    |     66.67 |       100 |        50 |     66.67 |
      test1.js     |       100 |       100 |       100 |       100 |
      test2.jsx    |       100 |       100 |       100 |       100 |
      test3.coffee |       100 |       100 |       100 |       100 |
-------------------|-----------|-----------|-----------|-----------|
All files          |     96.55 |       100 |     91.67 |     96.55 |
-------------------|-----------|-----------|-----------|-----------|
```<commit_msg>up doc<commit_after>gulp-jsx-coverage
=================

Enable coverage on .JSX or .coffee files.

[![npm version](https://img.shields.io/npm/v/gulp-jsx-coverage.svg)](https://www.npmjs.org/package/gulp-jsx-coverage) [![Dependency Status](https://david-dm.org/zordius/gulp-jsx-coverage.svg)](https://david-dm.org/zordius/gulp-jsx-coverage) [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE.txt)

**This is not a gulp plugin, it just a task creator to help you deal with istanbul instrumenter and collect coverage report in gulp**

**NOTE: coffee html/lcov report is buggy now**

Install
-------

```
npm install gulp-jsx-coverage
```

Usage
-----

* The golden rule: **Use .jsx as ext name**

```javascript
gulp.task('your_task_name', require('gulp-jsx-coverage').createTask({
    src: ['test/**/*.js', 'test/components/*.jsx'],  // will pass to gulp.src
    istanbul: {                                      // will pass to istanbul
        coverageVariable: '__MY_TEST_COVERAGE__',
        exclude: /node_modules|\/test\//             // pattern to skip instrument
    },
    coverage: {
        reporters: ['text-summary', 'json', 'lcov'],
        directory: 'coverage'                        // will pass to istanbul reporters
    },
    mocha: {                                         // will pass to mocha
        reporter: 'tap'
    },
    react: {                                         // will pass to react-tools
        sourceMap: true
    },
    coffee: {                                        // will pass to coffee.compile
        sourceMap: true
    }
}));
```

Live Example
------------

```sh
git clone https://github.com/zordius/gulp-jsx-coverage.git
cd gulp-jsx-coverage
npm install
npm test
```

Output:

```
> gulp-jsx-coverage@0.0.1 test /Users/zordius/gulp-jsx-coverage
> gulp

[17:21:00] Using gulpfile ~/gulp-jsx-coverage/gulpfile.js
[17:21:00] Starting 'default'...


  test coverage
    ✓ should covered 

  test coverage
    ✓ should covered 


  2 passing (32ms)

-------------------|-----------|-----------|-----------|-----------|
File               |   % Stmts |% Branches |   % Funcs |   % Lines |
-------------------|-----------|-----------|-----------|-----------|
   test/           |     90.91 |        50 |     91.67 |     90.91 |
      target.js    |     66.67 |       100 |        50 |     66.67 |
      test1.js     |       100 |       100 |       100 |       100 |
      test2.jsx    |     93.33 |        50 |       100 |     93.33 |
      test3.coffee |     88.89 |        50 |       100 |     88.89 |
-------------------|-----------|-----------|-----------|-----------|
All files          |     90.91 |        50 |     91.67 |     90.91 |
-------------------|-----------|-----------|-----------|-----------|
```
{'fraction_non_alphanumeric': 0.2330759561860298, 'fraction_numerical': 0.03591309032142216, 'mean_word_length': 1.3285953177257526, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 12, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1287142', 'n_tokens_mistral': 1862, 'n_tokens_neox': 1669, 'n_words': 373}