Home

Awesome

mochapack Join the chat at https://gitter.im/sysgears/mochapack npm package Build Status Twitter Follow

This project is a fork of mocha-webpack. We have created this fork since there is no visible activity from original author for a long time.

mocha test runner with integrated webpack precompiler

mochapack 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

mochapack ...

Benefits over plain mocha

Watch mode (--watch)

Unlike mocha, mochapack 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 mochapack?

mochapack works with

Installation

Install mochapack via npm install

$ npm install webpack mocha mochapack --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

mochapack simple.test.js

run all tests by glob

mochapack "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)

mochapack --glob "*.test.js" test

Watch mode? just add --watch

mochapack --watch test

Contributing

This project uses nari package manager to have reproducible builds without resorting to lockfiles, it uses lockTime field in package.json instead.

To install nari execute: npm i -g nari

And then nari to install the project.

To run project scripts use nari script_name, for example nari test to run unit tests.

License

This source code is licensed under the MIT license.<br/> Copyright © 2016-2017 Jan-André Zinser<br/> Copyright © 2018 SysGears (Cyprus) Limited.