steal-mocha

2.0.1 • Public • Published

Build Status npm version

steal-mocha

Provides an easy way to automatically run Mocha tests using StealJS.

Use

Add the Steal tag to your page

<script src="node_modules/steal/steal.js"
  mocha="bdd"
  main="test/test"></script> 

This will do the equivalent of

mocha.setup("bdd");

and your tests will automatically be ran.

Writing tests

When you write tests just be sure to import steal-mocha.

import "steal-mocha";
 
describe("Foo", function(){
  it("bar", function(){
    assert("yay!");
  });
});

Use with Bower / manually

If you are not using NPM the following configuration is necessary:

System.config({
  "paths": {
      "steal-mocha": "path/to/steal-mocha/steal-mocha.js",
      "steal-mocha/*": "path/to/steal-mocha/*.js",
      "mocha": "path/to/mocha/mocha.js",
      "mocha/mocha.css": "path/to/mocha/mocha.css"
  },
  "meta": {
      "mocha": {
          "format": "global",
          "exports": "mocha",
          "deps": [
              "steal-mocha/add-dom"
          ]
      }
  }
});

mocha.opts

Mocha's runner allows for a mocha.opts file, specifying addition options such as checkLeaks(). steal-mocha does not parsed a mocha.opts file, however allows the specification of a startup script.

This is similar to the --require option in mocha.opts.

<script src="node_modules/steal/steal.js"
  mocha-require="test/setup"
  main="test/test"></script> 

The path in data-mocha-require is a module name.

test/setup.js

const chai = require('chai');
const sinon = require('sinon');
 
module.exports = function(mocha) {
  sinon.assert.expose(chai.assert, { prefix: '' });
};

The above example extends Chai's assertion library with SinonJS assertions.

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i steal-mocha

Weekly Downloads

23

Version

2.0.1

License

MIT

Unpacked Size

5.91 kB

Total Files

6

Last publish

Collaborators

  • juk3
  • justinbmeyer
  • m-mujica
  • matthewp