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

mocha-qunit-ui

v0.1.3

Published

An interface for Mocha that implements QUnit's API.

Downloads

3,377

Readme

Mocha QUnit UI

Build Status

An interface for Mocha that implements QUnit's API.

Mocha ships with a QUnit interface, but it lacks assertions, support for expected assertion count, and the asyncTest method (among other things). This is an alternate implementation that fully supports the entire QUnit API. It may be run either in Node.js or the browser. The goal is to get as close as possible to being able to run QUnit tests unaltered in Mocha.

Installation

$ npm install mocha-qunit-ui --save-dev

Usage

Node.js

From the command line:

$ mocha --ui mocha-qunit-ui test/test-file-1.js

Programatically:

// Load mocha-qunit-ui
require("mocha-qunit-ui");
// Tell mocha to use the interface.
var mocha = new Mocha({
  ui:"qunit"
});
// Add your test files
mocha.addFile("path/to/my/testfile.js");
// Run your tests
mocha.run(function(failures){
  process.exit(failures);
});

Browser environments

Declare an HTML file with the following markup to run tests in the browser:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Tests</title>
    <script src="path/to/mocha.js"></script>
    <script src="mocha-qunit-ui.js"></script>
    <script>
      mocha.setup({
        ui: "qunit"
      });
    </script>
    <link rel="stylesheet" type="text/css" href="path/to/mocha.css">
  </head>
  <body>
    <div id="mocha"></div>
    <script>
      module("On page test!");
      test("An awesome QUnit style test", 2, function () {
        ok(true);
        equal(1, parseInt("1"));
      });
      mocha.run();
    </script>
  </body>
</html>

You can also use qunit-mocha-ui from Grunt with the grunt-mocha task. Here's an example Gruntfile.js:

module.exports = function(grunt) {
  grunt.loadNpmTasks('grunt-mocha');
  grunt.initConfig({
    mocha: {
      test:{
        options:{
          mocha: {
            ui: 'qunit'
          }
        },
        src: [
          "test/test-file-1.js"
        ]
      }
    }
  });
  grunt.registerTask('default', ['mocha']);
};

Known differences from QUnit API

  • The global variable module is reserved in Node.js. If you want to define a QUnit module in that environment, use the QUnit.module alias.

Running tests

  1. Install dependencies: npm install
  2. Update QUnit submodule git submodule update --init --recursive
  3. npm test

You can run QUnit's test suite by opening test/qunit.html in a browser.

License

Copyright (c) 2013 Mike Pennisi
Licensed under the MIT license.