Skip to content
Mocha test runner with integrated webpack precompiler
TypeScript JavaScript Other
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Add PR template Sep 21, 2019
bin Upgrade chokidar to 3.3.0 Nov 7, 2019
docs Update docs to reflect this project uses Yarn (#32) Oct 7, 2019
examples/debug-webpack4 Upgrade to Typescript (#50) Dec 12, 2019
lib Core refactoring (#78) Dec 7, 2016
src Add Prettier and improve ESLint (#51) Dec 15, 2019
test Add Prettier and improve ESLint (#51) Dec 15, 2019
.babelrc Upgrade to Typescript (#50) Dec 12, 2019
.bookignore optimize deployment (#224) Mar 21, 2018
.editorconfig initial commit Feb 13, 2016
.eslintignore pretty webpack build errors / warnings (#99) Jan 9, 2017
.eslintrc.json Add Prettier and improve ESLint (#51) Dec 15, 2019
.gitattributes limit lf endings to text files (#221) Mar 20, 2018
.gitignore Update docs to reflect this project uses Yarn (#32) Oct 7, 2019
.prettierignore Add Prettier and improve ESLint (#51) Dec 15, 2019
.travis.yml Update integrations to use Yarn (#33) Oct 7, 2019
CONTRIBUTING.md Update docs to reflect this project uses Yarn (#32) Oct 7, 2019
LICENSE.md Rename project mocha-webpack -> mochapack Mar 1, 2019
README.md Update Linux Travis badge Jun 4, 2019
SUMMARY.md Update dependencies to enable Greenkeeper 🌴 (#223) Mar 21, 2018
appveyor.yml Update integrations to use Yarn (#33) Oct 7, 2019
book.json Add Prettier and improve ESLint (#51) Dec 15, 2019
package.json Add Prettier and improve ESLint (#51) Dec 15, 2019
tsconfig.json Add Prettier and improve ESLint (#51) Dec 15, 2019
tsconfig.lint.json Add Prettier and improve ESLint (#51) Dec 15, 2019
yarn.lock Add Prettier and improve ESLint (#51) Dec 15, 2019

README.md

mochapack Join the chat at https://gitter.im/sysgears/mochapack npm package Build Status Linux Build Status Windows codecov 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 ...

  • 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
  • mochapack provides a much better watch mode than 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

  • webpack in version 4.x.x
  • mocha in version 4.x.x, 5.x.x, 6.x.x

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

License

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

You can’t perform that action at this time.