包详细信息

mocha-runner

royriojas271MIT3.0.1

A simple mocha runner that includes chai, sinon, sinon-chai and chai-fuzzy and accepts a list of globs to run

mocha, runner, chai, chai-sinon

自述文件

NPM Version Build Status

mocha-runner

A simple mocha runner that includes chai, sinon, sinon-chai and chai-fuzzy and accepts a list of globs to run

Motivation

install

# usually is enough to install it as a dev dependency since this is for testing
npm i --save-dev mocha-runner

usage

Options

`mocha-runner` is yet another mocha cli with includes sinon, mocha and chai

========================================================
Usage: mocha-runner [options] glob [glob1] [glob2]..[globN]
========================================================

Options:
  -u, --use-cache        If true will filter the files returning only the ones that changed after the last run, if this is false the cache will be
                         destroyed and created again the next time this flag is set to true. By default this is false
  -g, --grep String      only run tests matching
  -f, --fgrep String     only run tests matching
  -b, --bail             fail on the first error
  -r, --reporter String  Reporter, default to spec
  -t, --timeout Number   mocha tests timeout
  -h, --help             Show this help
  -v, --version          Outputs the version number
  -q, --quiet            Show only the summary info - default: false
  --colored-output       Use colored output in logs
  --stack                if true, uncaught errors will show the stack trace if available
  -c, --config String    path to your mocha config. If none provided, it will first try to find a `./mocha.json` file in the current directory. If
                         none found it will use the default ones. See mocha options here: http://mochajs.org/

Example

From the command line

# or node node_modules/mocha-runner/bin/runner.js if installed as dev-dependency
mocha-runner --config='./path-to-mocha-config.json' 'specs/**/*.js' 'another/directory/**/*.js'

or in your package.json, (Recommended), paired with istanbul and watch-spawn

{
  "scripts": {
     // simple example for running tests
     "test": "mocha-runner 'specs/**/*.js'",
     // use it with istanbul to generate nice coverage reports
     "coverage": "istanbul cover -x 'specs/**/*.js' ./bin/runner.js 'specs/**/*.js' html text-summary",
     // use the useCache option to only run the tests that changed
     "coverage-cache": "istanbul cover -x 'specs/**/*.js' ./bin/runner.js 'specs/**/*.js' html text-summary -- --useCache=true",
     // pair it with watch-spawn and execute the tests only on the specs that changed
     // or when the sources files change, this will save tons of time if running this on a project with several files
     // Or at least save some noise to focus only on the modified specs.
     "watch": "npm run coverage && watch-spawn -p 'specs/**/*.js' -p 'bin/**/*.js' -p 'lib/**/*.js' npm run coverage-cache"
  }
}

then you can do

npm run test # will execute the tests
npm run coverage # will generate a coverage report
npm run coverage-cache # will execute only the test that changed. Coverage report is only of the changed files
npm run watch # will watch for changes on the specified files and run

Changelog

更新日志

mocha-runner - Changelog

v3.0.1

  • Build Scripts Changes

v3.0.0

  • Refactoring
    • Upgrade deps to remove nasty audit warning - 96c2a82, Roy, 11/06/2019 03:09:00

v2.0.1

  • Refactoring

v2.0.0

v1.1.2

  • Bug Fixes
    • wrong help description and add timeout option in cli - cb4924b, Roy Riojas, 25/03/2016 19:42:22

v1.1.1

v1.1.0

  • Refactoring
    • Updated to use latest clix and support grep - 853ff9d, royriojas, 15/08/2015 03:29:45
  • Enhancements
  • Build Scripts Changes

v1.0.8

  • Build Scripts Changes
  • lock dependencies with a shrinkwrap.json file - 483e9a8, Roy Riojas, 18/03/2015 03:58:34
  • Bug Fixes

v1.0.6

  • remove peerDeps as they are going to be removed from next npm version - fe64ded, Roy Riojas, 10/03/2015 02:48:29
  • use a version of sinon that works with sinon-chai - 2663ea1, Roy Riojas, 10/03/2015 02:23:57
  • Add peer deps as dev deps to try to fix the build breaking - 6128642, Roy Riojas, 09/03/2015 05:08:09
  • Features
    • move deps to peer dependencies and revert to previous sinon version because of issue with sinon.matchers - 862ee72, Roy Riojas, 09/03/2015 04:28:33
  • Simple mocha runner with chai sinon and fuzzy - a06928a, Roy Riojas, 09/03/2015 01:55:07