GithubHelp home page GithubHelp logo

isabella232 / mocha-webpack Goto Github PK

View Code? Open in Web Editor NEW

This project forked from substancelab/mocha-webpack

0.0 0.0 0.0 2.43 MB

mocha test runner with integrated webpack precompiler

Home Page: http://zinserjan.github.io/mocha-webpack/

License: MIT License

JavaScript 99.75% CoffeeScript 0.12% TypeScript 0.07% CSS 0.06%

mocha-webpack's Introduction

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

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 4.x.x
  • mocha in version 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

mocha-webpack's People

Contributors

zinserjan avatar randycoulman avatar astorije avatar terrenceljones avatar modosc avatar alexmeah avatar azhang avatar darrinholst avatar ezze avatar flui avatar yachaka avatar jleft avatar nickradford avatar pkuczynski avatar thiagoa avatar vikhyat avatar greenkeeper[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.