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

lichtenberg

v0.0.4

Published

A tracing program for your JavaScript apps.

Downloads

2

Readme

Lichtenberg

Lichtenberg figure, made by high-voltage electrical discharge through a block of acrylic

A JavaScript code coverage and debugging library. Still in alpha.

NPM version NPM downloads License

What is it?

Lichtenberg reads your code and annotates it with trace statements. Then, when you view your tests in a browser, it watches for those trace statements and keeps track of how many were run. From this, it creates a coverage report telling you how much of your code was actually run during the test. Strive for 100%!

Lichtenberg aims to be as independent as possible of whatever testing framework you choose. It's been proven to work with Mocha, but should also work with QUnit, Jasmine, etc.

Installing

$ npm install -g lichtenberg

Trying it out

You can try Lichtenberg with the sample test folder included in this repository. Requires Grunt.

$ git clone https://github.com/baconscript/lichtenberg.git
$ cd lichtenberg
$ npm install && grunt
$ cd test
$ lichtenberg

Try adding more tests in test.html and watching the coverage go up! The library being tested is format.

Setup

To run Lichtenberg coverage on your project, first create a lichtenberg.json file in your project root.

{
  "entry": "test.html",
  "include": ["assets"],
  "exclude": ["bower_components"],
  "serveAs": "/apps/myApp"
}
  • entry: HTML page that runs your tests. Lichtenberg will inject a couple of script tags and a div into it to generate the code coverage.
  • include: Regular expression indicating which files to instrument for coverage.
  • exclude: Regular expression indicating which files to ignore when instrumenting. Good candidates for this would be any external libraries you're using.
  • serveAs: Path to your entry point on the server. This is helpful if you have absolute paths in your code and need to preserve them. For instance, if your test page is served at /apps/myApp/test.html, setting serveAs to be /apps/myApp will serve all the files in the project from that path.

Add __Lichtenberg.done() to your code

In your test suite, add the following code in a place where it will run after all tests should have completed.

if(window.__Lichtenberg) {
  __Lichtenberg.done();
}

Or, if you want something shorter: window.__Lichtenberg && __Lichtenberg.done()

In Mocha's BDD style, this may be achieved by wrapping all your tests in a describe() and adding the code to an after() function.

When done() is called, Lichtenberg runs through all the lines of code that it is aware of, computes coverage on each file, and displays the results in your browser.

Running

From the same directory as your lichtenberg.json file, just type lichtenberg to start the server. Visit http://localhost:9796 in your browser to view the results. Report generation is coming soon.

Sample tests using Mocha