Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

istanbul-react

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

istanbul-react

Instrumenter for 1:1 mapping of React JSX components

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
21
decreased by-52.27%
Maintainers
2
Weekly downloads
 
Created
Source

istanbul-react Build Status Dependency Status

Instrumenter for 1:1 mapping of React JSX components, can be used with karma-coverage

Install

$ npm install --save-dev istanbul-react

Usage

Use with karma-coverage

coverageReporter: {
  instrumenters: { 'istanbul-react' : require('istanbul-react') }
  instrumenter: {
    '**/*.jsx': 'istanbul-react'
  },
  // ...
}

You can also just use it directly

var instrumenter = new require('istanbul-react').Instrumenter({});

instrumenter.instrument(content, path, function(err, instrumentedCode) {
  // ...
});

Options

You can use modifyCodeBeforeInstrumentation to modify code before instrumentation. It might be useful for example to get around chrome bug with 'use strict';. It takes one argument, which give you an object, with two properties code - original code, filename - name of the file. This callback must return modified code as a string. In the example below you can see how 'use strict'; is prefixed with semi-colon to work around bug (or feature?) in chrome.

coverageReporter: {
  instrumenters: { 'istanbul-react' : require('istanbul-react') }
  instrumenter: {
    '**/*.jsx': 'istanbul-react'
  },
  instrumenterOptions: {
    'istanbul-react': {
      modifyCodeBeforeInstrumentation: function fixChromeBugWithUseStrict(params) {
        return params.code.replace(/(['"]use strict['"];)/g, ';$1');
      }
    }
  },
  // ...
}

Tests

$ npm test

License

MIT © Podio

Keywords

FAQs

Package last updated on 05 Aug 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc