All Projects → privatenumber → instant-mocha

privatenumber / instant-mocha

Licence: MIT license
☕️ Build tests with Webpack and run with Mocha in one command

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to instant-mocha

xv
❌ ✔️ zero-config test runner for simple projects
Stars: ✭ 588 (+1407.69%)
Mutual labels:  mocha, runner
taskrunner
🍑 a configurable task runner written in go
Stars: ✭ 28 (-28.21%)
Mutual labels:  runner
typeplate
REST API boilerplate with Typescript, Express.js, Typeorm and Mocha.
Stars: ✭ 268 (+587.18%)
Mutual labels:  mocha
template-server-nodejs
No description or website provided.
Stars: ✭ 20 (-48.72%)
Mutual labels:  mocha
playwright-test
Run unit tests with several runners or benchmark inside real browsers with playwright.
Stars: ✭ 81 (+107.69%)
Mutual labels:  mocha
api-skel
Webpack + Typescript + Express + Jest + Chai + Gulp
Stars: ✭ 18 (-53.85%)
Mutual labels:  mocha
Swatch
Watcher for Unit Tests written in Swift
Stars: ✭ 55 (+41.03%)
Mutual labels:  runner
BotBlock.org
BotBlock - The List of Discord Bot Lists and Services
Stars: ✭ 29 (-25.64%)
Mutual labels:  mocha
aria-vue
Testing tools for Vue components
Stars: ✭ 21 (-46.15%)
Mutual labels:  mocha
python-appium-framework
Complete Python Appium framework in 360 degree
Stars: ✭ 43 (+10.26%)
Mutual labels:  runner
react-testing-mocha-chai-enzyme
A solid test setup for React components with Mocha, Chai, Sinon, Enzyme in a Webpack/Babel application.
Stars: ✭ 48 (+23.08%)
Mutual labels:  mocha
vue-webpack-boilerplate
A webpack boilerplate with vue-loader, axios, vue-router and vuex
Stars: ✭ 51 (+30.77%)
Mutual labels:  mocha
givens
Easy test setup without side effects.
Stars: ✭ 22 (-43.59%)
Mutual labels:  mocha
cargo-limit
Cargo with less noise: warnings are skipped until errors are fixed, Neovim integration, etc.
Stars: ✭ 105 (+169.23%)
Mutual labels:  runner
cypress-slack-reporter
A home for various Cypress Plugins
Stars: ✭ 126 (+223.08%)
Mutual labels:  mocha
js-stack-from-scratch
🌺 Russian translation of "JavaScript Stack from Scratch" from the React-Theming developers https://github.com/sm-react/react-theming
Stars: ✭ 394 (+910.26%)
Mutual labels:  mocha
node-url-shortener
URL Shortener in Base58 using Node.js, Express, Sequelize, Mocha and Bootstrap
Stars: ✭ 21 (-46.15%)
Mutual labels:  mocha
duty
A simple task runner.
Stars: ✭ 36 (-7.69%)
Mutual labels:  runner
Elaina
🔮 Docker-based remote code runner. / 基于 Docker 的远程代码运行器
Stars: ✭ 36 (-7.69%)
Mutual labels:  runner
titef
🌠 A tiny, lightning-fast, zero-dependecies JavaScript test framework 🌠
Stars: ✭ 19 (-51.28%)
Mutual labels:  mocha

instant-mocha

Build tests with Webpack and run them with Mocha in one command

Features

  • Source-map support
  • Builds and runs in-memory
  • Inherits Mocha CLI
  • Supports Webpack 5 & Mocha 8

How does it compare to mocha-webpack / mochapack? Answered in the FAQ.

Support this project by ⭐️ starring and sharing it. Follow me to see what other cool projects I'm working on! ❤️

🚀 Install

npm i -D mocha webpack instant-mocha

Note: webpack and mocha are peer-dependencies so you can provide any version

👨‍🏫 Usage

instant-mocha --webpack-config <Webpack config path> [test paths/globs...]

You can either use npx (eg. npx instant-mocha ...) or add it to package.json scripts (eg. npm test) to invoke it.

Options

--webpack-config

Path to the Webpack config.

-w, --watch

Watch mode. Re-compiles the Webpack build and re-run tests on file-changes.

Supports all options from Mocha CLI

For more info, run:

instant-mocha --help

Example

instant-mocha ---webpack-config webpack.config.js --require setup.js 'tests/*.spec.js'
  • Load Webpack config from webpack.config.js
  • Load setup script from setup.js. Note, this is not apart of the build and is loaded directly from Node.js
  • Find and run tests that matches glob tests/*.spec.js

💁‍♀️ FAQ

How do I enable source-maps?

Set devtool: 'source-map' in your Webpack config.

How do I add a progress bar?

Add webpackbar to your Webpack config.

Are node_modules automatically externalized?

They can't be automatically externalized because it's possible some dependencies require bundling or pre-processing. For example, packages in ESM format or deep-dependencies that are stubbed for testing.

It's recommended to externalize what you can in your Webpack config to speed up the build though. Consider using webpack-node-externals to do this.

How is it different from mocha-webpack or its fork mochapack?

First of all, major thanks to mocha-webpack for the original implementation and serving the community.

This project was created from scratch because mocha-webpack is no longer maintained and doesn't have Webpack 5 support.

Some notable improvements include:

  • Written in TypeScript whereas mocha-webpack uses Flow.
  • Doesn't re-implement another file-watching mechanism Relies on Webpack's watcher instead.
  • Loosely coupled with Mocha and Webpack The API surface used is very narrow so it works with most versions, (eg. Webpack 4 & 5).
  • Correct exit codes Mocha and mocha-webpack returns the number of failed tests as the exit code. instant-mocha only uses exit code 1 for any test failures as per Bash convention.
  • Smaller size Reuses a lot from Webpack & Mocha so it's much lighter: instant-mocha install size vs mocha-webpack install size

💼 License

MIT © Hiroki Osame

Logo made by monkik

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].