mocha-webpack
mocha cli with webpack support
Last updated 7 years ago by zinserjan .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install mocha-webpack 
SYNC missed versions from official npm registry.

mocha-webpack npm package Build Status Linux Build Status Windows codecov

mocha test runner with integrated webpack precompiler

mocha-webpack is basically a wrapper around the following command...

$ webpack test.js output.js && mocha output.js

... but in a much more powerful & optimized way.

CLI

mocha-webpack ...

  • precompiles your test files automatically with webpack before executing tests
  • handles source-maps automatically for you
  • does not write any files to disk
  • understands globs & all other stuff as test entries like mocha

Benefits over plain mocha

  • has nearly the same CLI as mocha
  • you don't rely on hacky solutions to mock all benefits from webpack, like path resolution
  • mocha-webpack provides a much better watch mode than mocha

Watch mode (--watch)

Unlike mocha, mocha-webpack analyzes your dependency graph and run only those test files that were affected by this file change.

You'll get continuous feedback whenever you make changes as all tests that are related in any way to this change will be tested again. Isn't that awesome?

If any build errors happens, they will be shown like below

CLI

Which version works with mocha-webpack?

mocha-webpack works with

  • webpack in version 2.x.x & 3.x.x
  • mocha in version 2.x.x, 3.x.x, 4.x.x & 5.x.x

Installation

Install mocha-webpack via npm install

$ npm install webpack mocha mocha-webpack --save-dev

and use it via npm scripts in your package.json

Further installation and configuration instructions can be found in the installation chapter.

Sample commands

run a single test

mocha-webpack simple.test.js

run all tests by glob

mocha-webpack "test/**/*.js"

Note: You may noticed the quotes around the glob pattern. That's unfortunately necessary as most terminals will resolve globs automatically.

run all tests in directory "test" matching the file pattern *.test.js (add --recursive to include subdirectories)

mocha-webpack --glob "*.test.js" test

Watch mode? just add --watch

mocha-webpack --watch test

License

MIT

Current Tags

  • 1.1.0                                ...           latest (7 years ago)
  • 2.0.0-beta.0                                ...           next (7 years ago)

21 Versions

  • 2.0.0-beta.0                                ...           7 years ago
  • 2.0.0-alpha.0                                ...           7 years ago
  • 1.1.0                                ...           7 years ago
  • 1.0.1                                ...           7 years ago
  • 1.0.0                                ...           7 years ago
  • 1.0.0-rc.1                                ...           7 years ago
  • 1.0.0-rc.0                                ...           7 years ago
  • 1.0.0-beta.1                                ...           8 years ago
  • 1.0.0-beta.0                                ...           8 years ago
  • 0.7.0                                ...           8 years ago
  • 0.6.0                                ...           8 years ago
  • 0.5.0                                ...           8 years ago
  • 0.4.0                                ...           8 years ago
  • 0.3.1                                ...           9 years ago
  • 0.3.0                                ...           9 years ago
  • 0.2.0                                ...           9 years ago
  • 0.1.0                                ...           9 years ago
  • 0.0.1-alpha.4                                ...           9 years ago
  • 0.0.1-alpha.3                                ...           9 years ago
  • 0.0.1-alpha.2                                ...           9 years ago
  • 0.0.1-alpha.1                                ...           9 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (17)

Copyright 2013 - present © cnpmjs.org | Home |