npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

typhonjs-istanbul-instrument-jspm

v0.1.0

Published

Provides a NPM module to add Istanbul instrumentation to JSPM / SystemJS by replacing the System.translate hook.

Downloads

54

Readme

typhonjs-config-jspm-parse

NPM Code Style License Gitter

Build Status Coverage Dependency Status

Provides a NPM module to add Istanbul instrumentation to JSPM / SystemJS by replacing the System.translate hook.

By using this module SystemJS can be instrumented for code coverage with Istanbul with minimal effort.

For a comprehensive ES6 build / testing / publishing NPM module please see typhonjs-npm-build-test as it combines this module along with transpiling ES6 sources with Babel, pre-publish script detection, ESDoc dependencies, testing with Mocha / Istanbul and an Istanbul instrumentation hook for JSPM / SystemJS tests.

Please review istanbul-jspm-coverage-example for a complete working example which uses typhonjs-npm-build-test and subsequently this module which is included as a dependency to typhonjs-npm-build-test.


In short an ES6 Mocha test that instruments Istanbul will do the following:

import jspm                      from 'jspm';

import instrumentIstanbulSystem  from 'typhonjs-istanbul-instrument-jspm';

// Set the package path to the local root where config.js is located.
jspm.setPackagePath(process.cwd());

// Create SystemJS Loader
const System = new jspm.Loader();

// Replaces System.translate with version that provides Istanbul instrumentation.
instrumentIstanbulSystem(System);

instrumentIstanbulSystem takes two parameters:

(object)   System - An instance of SystemJS.

(RegExp)   sourceFilePathRegex - (optional) A regex which defines which source files are instrumented; default excludes
                                 any sources with file paths that includes `jspm_packages`.

It should be noted that the default source file path regex is defined as /^((?!jspm_packages).)*$/ which excludes any sourcecode loaded from jspm_packages. You may optionally pass in a regex as the second parameter to instrumentIstanbulSystem. An example of excluding both jspm_packages and ./test/src is: instrumentIstanbulSystem(System, /^((?!jspm_packages|test\/src\/).)*$/);.

A final important detail when using Istanbul is that the cover command will not pickup the source instrumented via typhonjs-istanbul-instrument-jspm when an initial report is generated, however the instrumentation is represented in coverage.raw.json. To make sure SystemJS sources are represented in the final report simply run the Istanbul report command and the original source will be included in the report. This is automated by the mocha-istanbul-report NPM script that is included as part of typhonjs-npm-build-test / typhonjs-npm-scripts-test-mocha.

In package.json add an NPM script like the following:

"scripts": {
  "test-coverage": "babel-node ./node_modules/typhonjs-npm-scripts-test-mocha/scripts/mocha-istanbul-report.js"
}

Please note that the TyphonJS NPM scripts use a separate configuration file ./npmscriptrc to define various actions. For further information refer to typhonjs-npm-scripts-test-mocha