mochista
Mocha + Istanbul in a single process
Last updated a year ago by laggingreflex .
Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install mochista 
SYNC missed versions from official npm registry.

Mochista

npm

Like* Mocha + Istanbul c8* in a single process.

Mochista uses Mocha and Istanbul c8's programmatic API to run both in a single process* yielding fastest test results and coverage reports.

Its --watch feature runs modified tests and generates coverage using cache for unmodified files instantly:

Protip: Use --coverage-server flag to run live-server (via npx) on the coverage dir to view live changes to coverage reports.

Update: Major Rewrite

Uses c8

After recently discovering c8 I decided to rewrite this to use that instead of Istanbul. But c8 still uses Istanbul under the hood to generate reports and such, so the overall outcome of this change should be more or less the same as before.

Also running everything in single-process is also no longer the case, since c8 uses Node's built in coverage functionality which only outputs coverage data once the Node processes has exited, tests now need to be run in a separate (forked) process. There doesn't seem to be too much of a noticeable performance hit, since forked processes are still quicker than separate shell commands.

Not all features of Mocha and Istanbul supported

Incorporating all functionalities of both Mocha and Istanbul is no longer the intent of this project. Earlier this project may have claimed to be a drop-in replacement for both, but that is no longer the case (in hindsight it wasn't a wise decision to begin with, since there were/would've been a lot of flag/features collisions). It'll however still try to support some of the most common features (bail, fgrep) with direct flags or --mocha-xxx prefix.

Node v10.10

Another thing this rewrite did was to massively simplify the code (1.3k->300 LOC), and some of the features (Async Iteration) are heavily reliant on latest NodeJS (v10).

I don't currently plan to use babel to transpile-down.

Also c8 uses Node's built in coverage functionality which requires Node >= v10.10.

Features

  • Run tests and generate coverage reports

  • Like mocha --watch but with Istanbul coverage reports.

Note: Following features have been removed since the update.

  • Run only modified tests. It's far simpler (and not that slow) to just re-run everything.

  • Instrumentation caching on disk and memory for fastest coverage report generation and re-generation. Not needed anymore.

  • Supports mocha.opts with extra features. See above. It does support .env file (via dotenv) and all can take all command-line flags from it (via yargs' .env feature)

  • Built in support for ES6/ES2015+ by using coverage source-maps. See below

Install

npm i -g mochista

Usage

mochista [options]
Options:
  --help             Show help  [boolean]
  --version          Show version number  [boolean]
  --cwd              Current dir  [string]
  --testFiles, -t    Files to test (anymatch)  [array] [default: ["*test*/**","**/*.test.*","**/test.*"]]
  --sourceFiles, -s  Source files (for coverage) (anymatch)  [array] [default: ["."]]
  --exclude          Files to exclude (anymatch)  [array] [default: [".*","node_modules","coverage"]]
  --gitignore        Files to exclude based on .gitignore  [string] [default: [".gitignore","~/.gitignore"]]
  --extensions       Extensions to monitor (all other files ignored)  [array] [default: [".js"]]
  --watch, -w        Watch for file changes and re-run. `--watch=i` to only re-run on pressing Enter
  --parallel         Use mocha-parallel-tests to run each of your test files in a separate process
  --coverage         Collect coverage (use --no-coverage to disable)  [boolean] [default: true]
  --coverageDir      Directory to output coverage and reports  [string] [default: "./coverage"]
  --coverageServer   Run live-server (via npx) on coverage dir  [boolean]
  --reporter         Mocha reporter  [string] [default: "spec"]
  --report           Istanbul reporters  [array] [default: ["text","lcov","html"]]
  --require, -r      Require the given module  [array] [default: []]
  --all, -a          Instrument all files  [boolean]
  --mocha-xxx        All mocha-related options, like --mocha-fgrep etc
  --config           JS/JSON config file path

Options can be provided in --camelCase, --hyphen-case or set as environment variables (which can also be read from .env file) in UPPER_SNAKE_CASE=.

Other than explicitly setting a boolean to =false, you can also use the --no- prefix, like --no-coverage

Issues

Transpilers

Personally not a huge fan of transpilers (babel, typescript) so they've neither been tested nor support for them is provided currently.

Libraries used

Current Tags

  • 0.21.1                                ...           latest (a year ago)

58 Versions

  • 0.21.1                                ...           a year ago
  • 0.21.0                                ...           a year ago
  • 0.20.4                                ...           a year ago
  • 0.20.2                                ...           2 years ago
  • 0.20.1                                ...           2 years ago
  • 0.20.0                                ...           2 years ago
  • 0.19.3                                ...           2 years ago
  • 0.19.2                                ...           2 years ago
  • 0.19.1                                ...           2 years ago
  • 0.19.0                                ...           2 years ago
  • 0.18.1                                ...           2 years ago
  • 0.18.0                                ...           2 years ago
  • 0.17.3                                ...           2 years ago
  • 0.17.2                                ...           2 years ago
  • 0.17.1                                ...           2 years ago
  • 0.17.0                                ...           2 years ago
  • 0.16.0                                ...           2 years ago
  • 0.15.1                                ...           2 years ago
  • 0.15.0                                ...           2 years ago
  • 0.14.0                                ...           2 years ago
  • 0.14.0-0                                ...           2 years ago
  • 0.13.0                                ...           3 years ago
  • 0.12.2                                ...           3 years ago
  • 0.12.1                                ...           3 years ago
  • 0.12.0                                ...           3 years ago
  • 0.11.0                                ...           3 years ago
  • 0.10.2                                ...           3 years ago
  • 0.10.1                                ...           3 years ago
  • 0.10.0                                ...           3 years ago
  • 0.9.2                                ...           3 years ago
  • 0.9.1                                ...           3 years ago
  • 0.9.0                                ...           3 years ago
  • 0.8.1                                ...           3 years ago
  • 0.8.0                                ...           3 years ago
  • 0.7.6                                ...           3 years ago
  • 0.7.5                                ...           3 years ago
  • 0.7.4                                ...           3 years ago
  • 0.7.3                                ...           3 years ago
  • 0.7.2                                ...           3 years ago
  • 0.7.1                                ...           3 years ago
  • 0.7.0                                ...           3 years ago
  • 0.6.1                                ...           3 years ago
  • 0.6.0                                ...           3 years ago
  • 0.5.0                                ...           3 years ago
  • 0.4.3                                ...           3 years ago
  • 0.4.2                                ...           3 years ago
  • 0.4.1                                ...           3 years ago
  • 0.4.0                                ...           3 years ago
  • 0.3.3                                ...           4 years ago
  • 0.3.2                                ...           4 years ago
  • 0.3.1                                ...           4 years ago
  • 0.3.0                                ...           4 years ago
  • 0.2.0                                ...           4 years ago
  • 0.1.2                                ...           4 years ago
  • 0.1.1                                ...           4 years ago
  • 0.1.0                                ...           4 years ago
  • 0.0.1                                ...           4 years ago
  • 0.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 1
Last Month 4
Dependencies (17)
Dev Dependencies (0)
None
Dependents (1)

Copyright 2014 - 2016 © taobao.org |