GithubHelp home page GithubHelp logo

plainspec-mocha-reporter's Introduction

plainspec-mocha-reporter

code style: prettier

plainspec reporter for Mocha.

The plainspec-mocha-reporter is a reporter for mocha.
Useful for scenarios when async calls are logged so that console is clean for test report and view.

Installation

Save it as dev dependency in your project npm install plainspec-mocha-reporter --save-dev

or

Do a npm install after plainspec-mocha-reporter as devDependencies to your package.json file

//package.json
"devDependencies": {
  ..
  "plainspec-mocha-reporter": "^1.0.9",
  ..
}

Usage

Refer Mocha Third party reporters

and then run to see output

mocha --reporter plainspec-mocha-reporter --check-leaks test/

or look at configuration options below.

For npm test in package.json in script section add

..
"scripts": {
    "test": "node_modules/mocha/bin/_mocha --reporter plainspec-mocha-reporter  test/*.js"
  },
..

Features and Differences

node_modules/mocha/bin/_mocha --reporter plainspec-mocha-reporter test/http*.js --exit --reporter-options epilogue

Screenshot

vs

node_modules/mocha/bin/_mocha --reporter spec test/http*.js --exit --reporter-options

Screenshot

Full configuration options

Parameter Effect
startMessage Starting Message (defaults to 'Release')
suitePad Padding used between suits,pass,fail (defaults to ' ')
rootMessage The report name (defaults to ' Mocha Custom Report ')
padCount Padding for the char in padChar. (defaults to '26')
padChar The char (defaults to '=')
epilogue enable disable epilogue (defaults to false)

Example output

mocha --reporter spec --check-leaks test/

  #hello world
    ✓ should return hello world


  1 passing (7ms)

with Custom report with symbol ok mocha --reporter plainspec-mocha-reporter --check-leaks test/

========================== Mocha Custom Start Report ==========================
	 Testing Release possibility
	 suite #hello world
		 ✓ should return hello world (1ms)
	 Summary: ✓ Passed:1 tests ✖ Failed:0 test Total:1/1
     Result: Release not possible
========================== Mocha Custom End Report ============================

where test/ folder has following test File

\\ test\test.js
"use strict";
var chai = require('chai')
var should = chai.should()
//test hello
describe('#hello world', function() {
  it('should return hello world', function() {
    let test = 'hello world';
    test.should.eql('hello world');
  });
});

and with symbol err

========================== Mocha Custom Start Report ==========================
	 Testing Release possibility
	 suite #hello world
		 ✖ should return hello world AssertionError: expected 'hello world' to deeply equal 'hello world nope'
    at Context.<anonymous> (test/test.js:8:17)
	 Result: Passed:0 Failed:1 Total:0/1
   Summary: ✓ Passed:0 tests ✖ Failed:1 test Total:0/1
   Result: Release not possible
========================== Mocha Custom End Report ============================

where test/ folder has following test File

\\ test\test.js
"use strict";
var chai = require('chai')
var should = chai.should()
//test hello
describe('#hello world', function() {
  it('should return hello world', function() {
    let test = 'hello world';
    test.should.eql('hello world nope');
  });
});

with customization node_modules/mocha/bin/_mocha --reporter index --check-leaks test/ --reporter-options rootMessage="StarShip Enterprise Test",padChar="+",padCount=30,suitePad=" ",startMessage="Take Off"


++++++++++++++++++++++++++++++StarShip Enterprise Test++++++++++++++++++++++++++++++
Testing Take Off possibility

   #Fly
   ✓ should return weapons ready (1ms)
   ✓ should return weather ok (0ms)
      #Pilots
      ✓ should return Pilots ready (0ms)
      ✓ should return Signal ready (0ms)
      ✓ should return Ammmo ready (0ms)
      ✖ should return Radar ready AssertionError: expected 'Radar ready' to deeply equal 'Radar not  ready'
    at Context.<anonymous> (test/nested-test.js:32:19) ~/plainspec-mocha-reporter/test/nested-test.js
   #Fleet Ready
   ✓ should be Fueled (0ms)
   ✓ should return check Engine (0ms)

Summary: ✓ Passed:7 tests ✖ Failed:1 test Total:7/8
Result: Take Off not possible

++++++++++++++++++++++++++++++StarShip Enterprise Test++++++++++++++++++++++++++++++

without node_modules/mocha/bin/_mocha --reporter index --check-leaks test/

========================== Mocha Custom Report ==========================
Testing Release possibility

 #Fly
 ✓ should return weapons ready (1ms)
 ✓ should return weather ok (0ms)
  #Pilots
  ✓ should return Pilots ready (0ms)
  ✓ should return Signal ready (0ms)
  ✓ should return Ammmo ready (0ms)
  ✖ should return Radar ready AssertionError: expected 'Radar ready' to deeply equal 'Radar not  ready'
    at Context.<anonymous> (test/nested-test.js:32:19) ~/plainspec-mocha-reporter/test/nested-test.js
 #Fleet Ready
 ✓ should be Fueled (0ms)
 ✓ should return check Engine (0ms)

Summary: ✓ Passed:7 tests ✖ Failed:1 test Total:7/8
Result: Release not possible

========================== Mocha Custom Report ==========================

Support

Feel free to reach out with your questions or concerns.PRs welcome.

Bipul K Kuri

plainspec-mocha-reporter's People

Contributors

bipulkkuri avatar dependabot[bot] avatar

Watchers

James Cloos 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.