Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Mocha test runner with integrated webpack precompiler

License

NotificationsYou must be signed in to change notification settings

sysgears/mochapack

Repository files navigation

This project is a fork ofmocha-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 morepowerful &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 versions4.x.x -5.x.x
  • mocha in versions5.x.x -9.x.x

Installation

Install mochapack via npm install

$ npm install webpack mocha mochapack --save-dev

and use it via npm scripts in yourpackage.json

Further installation and configuration instructions can be found in theinstallation 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 usesnari package manager to have reproducible builds without resorting to lockfiles, it useslockTime field inpackage.json instead.

To installnari execute:npm i -g nari

And thennari to install the project.

To run project scripts usenari script_name, for examplenari test to run unit tests.

License

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

About

Mocha test runner with integrated webpack precompiler

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors37


[8]ページ先頭

©2009-2025 Movatter.jp