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

crossbones

v0.1.0

Published

Framework for writing tests once and running them under any test engine

Downloads

5

Readme

Crossbones

Framework for writing tests once and running them under any test engine.

Currently, we only support conversion from Vows to Mocha. However, support for more frameworks is planned in the future.

Getting Started

Download crossbones.

In your web page:

<script src="crossbones.js"></script>
<script>
// Create a new test suite
var suite = new Skeleton('Sauron.js');

// Add in a test batch -- this is for a global mediator
suite.addBatch({
  'Sauron': {
    'can emit events': function () {
      Sauron.voice('hello');
    },
    'can set up functions to subscribe to events': function () {
      var works = false;
      Sauron.on('basicOn', function () {
        works = true;
      });
      Sauron.voice('basicOn');
      assert(works);
    },
    'can unsubscribe functions from events': function () {
      var count = 0;
      function basicOff() {
        count += 1;
      }

      Sauron.on('basicOff', basicOff);
      Sauron.voice('basicOff');
      Sauron.off('basicOff', basicOff);
      Sauron.voice('basicOff');
      assert(count === 1);
    }
  }
});

// Export the suite to mocha
suite.exportTo('Mocha');

// and run it
var runner = mocha.run();
</script>

Documentation

Skeleton exposes a constructor function to the window scope.

/**
 * Constructor for a Skeleton (test suite)
 * @param {String} name Name to call this test suite (may not apply to all BDD)
 */

Test suites have the methods of addBatchwhich is heavily based off of vows

/**
 * Method to add test batches to this test suite
 * @param {Object} batch Batch of tests to add to this test suite
 * @param {Object} batch.* Context containing a set of tests to run
 * @param {Function} batch.*.topic Topic function which takes the place of 'describe' in Mocha and 'topic' in Vows
 * @param {Function} batch.*.* Function that will run a test on the current topic
 * @param {String} batch.*.* Placeholder for a test that will be created later. These will be skipped for test suites that don't support them
 * @returns {this} Skeleton test suite that is being worked on
 */

and exportTo.

/**
 * Run method for a test suite (currently only supporting Mocha)
 * @param {Function|String} engineName If a function, Skeleton will process via it. Otherwise, Skeleton will retrieve the engine from its modules.
 * @returns {Mixed} Returns result of engine
 */

New test engines can be added via Skeleton.addModule(name, fn).

If a function is asynchronous, it must have an asynchronous flag set on it (fn.SKELETON_ASYNC = true;). Skeleton.async is a helper method that will set this flag for you:

var myAsyncFn = Skeleton.async(function () {
  return 1;
});
myAsyncFn.SKELETON_ASYNC; // true

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint your code via grunt.

Testing is currently done manually. You must serve the files locally (I suggest npm install -g serve && serve). Then, you can test Skeleton and its module tests respectively. Test results should be viewed via the console.

License

Copyright (c) 2013 Ensighten Licensed under the MIT license.