Giter VIP home page Giter VIP logo

mocha-multi's Introduction

mocha-multi

A bit of a hack to get multiple reporters working with mocha

Build Status NPM version

Usage

npm install mocha-multi --save-dev
mocha --reporter mocha-multi

Choosing Reporters

Set an environment variable called multi to specify the desired reporters. Reporters are listed as whitespace separated type=destination pairs.

multi='dot=- xunit=file.xml doc=docs.html' mocha -R mocha-multi

The special value of - (hyphen) for destination uses normal stdout/stderr.

How it works

A big hack that keeps changing the value of process.stdout and process.stderr whenever a reporter is doing its thing.

Seriously?

Yeah, Sorry!

All the hacks

This is very hacky, specifically:

  • The process and console objects get their internal state messed with
  • process.exit is hacked to wait for streams to finish writing
  • Only works if reporters queue writes synchronously in event handlers

Could this be a bit less hacky?

  • Now that mochajs/mocha#1059 is released the process.exit hack could be tidier

  • If mochajs/mocha#1061 is accepted upstream, I only need to hijack stdout, and can leave stderr alone

  • Having each reporter run in a child process would make it eaiser to capture their streams, but might lead to other issues

TODO

  • Update hack now that mochajs/mocha#1059 is merged
  • Add tests for coverage reports
  • Add tests which produce multiple reports at once
  • Add test for help text
  • Add test that uses --no-exit
  • Add test that doesn't use _mocha (maybe not?)

mocha-multi's People

Contributors

glenjamin avatar jtblin avatar fosrias avatar

Watchers

Kyle Fuller avatar Almad avatar  avatar Jakub Korál avatar Vladimír Gorej avatar Emmanuel Paraskakis avatar Jan Moravec avatar  avatar James Cloos avatar Tomáš Jeřábek avatar Ondřej Auer avatar  avatar Ilya Moskalev avatar Davita S. avatar Neha avatar  avatar  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.