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

soldat-mocha-test-runner

v1.0.0

Published

Run your Soldat package tests using Mocha

Downloads

2

Readme

Soldat Mocha Test Runner

By default, Soldat runs your tests with Jasmine (for more information on testing packages in Soldat, please see the Soldat Flight Manual). Soldat allows you to specify a custom test runner using the soldatTestRunner field in your package.json, but implementing a custom test runner is not straightforward. This module allows you to run your specs using Mocha with minimal fuss.

Installation

$ recrue install [--save-dev] soldat-mocha-test-runner

Usage

Default Test Runner

If you want to use all the default options, simply pass the module name as the soldatTestRunner value in your package.json:

{
  "name": "my-package",
  // ...
  "soldatTestRunner": "soldat-mocha-test-runner"
}

Note that your package.json may be cached by Soldat's compile cache when running tests with Soldat's GUI test runner, so if adding or changing that field doesn't seem to work, try quitting and restarting Soldat.

Programmatic Usage

If you'd like to perform more customization of your testing environment, you can create a custom runner while still utilizing soldat-mocha-test-runner for most of the heavy lifting. First, set soldatTestRunner to a relative path to a file:

{
  "name": "my-package",
  // ...
  "soldatTestRunner": "./test/custom-runner"
}

Then export a test runner created via the soldat-mocha-test-runner from test/custom-runner.js:

var createRunner = require('soldat-mocha-test-runner').createRunner

// optional options to customize the runner
var extraOptions = {
  testSuffixes: ['-spec.js', '-spec.coffee']
}

var optionalConfigurationFunction = function (mocha) {
  // If provided, soldat-mocha-test-runner will pass the mocha instance
  // to this function, so you can do whatever you'd like to it.
}

module.exports = createRunner(extraOptions, optionalConfigurationFunction)

API

createRunner([options,] [callback])

Returns a test runner created with the given options and callback. Both parameters are optional. The returned value can be exported from your soldatTestRunner script for Soldat to consume.

  • options - An object specifying customized options:

    • options.reporter [default: 'dot'] - Which reporter to use on the terminal
    • globalSoldat [default: true] - Whether or not to assign the created Soldat environment to global.soldat
    • testSuffixes [default: ['test.js', 'test.coffee']] - File extensions that indicate that the file contains tests
    • colors [default: true] - Whether or not to colorize output on the terminal
    • htmlTitle [default: ''] - The string to use for the window title in the HTML reporter

Making Assertions

soldat-mocha-test-runner does not include any assertion libraries; it only includes the Mocha test runner. You can pull in any assertion library you want, but Chai is a great choice.

const assert = require('chai').assert

describe('Testing', function () {
  it('works', function () {
    assert.equal(answerToLifeUniverseAndEverything, 42)
  })
})