npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@darrinholst/mocha-webpack

v1.0.2

Published

mocha cli with webpack support

Downloads

1

Readme

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

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