├── .gitignore ├── images └── screenshot.png ├── .travis.yml ├── .babelrc ├── .eslintrc ├── src └── index.js ├── README.md ├── LICENSE ├── package.json └── test └── index.js /.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | node_modules 3 | -------------------------------------------------------------------------------- /images/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MicheleBertoli/emoji-reporter/HEAD/images/screenshot.png -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: node_js 3 | node_js: 4 | - "6" 5 | before_script: 6 | - npm run build 7 | -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "es2015" 4 | ], 5 | "plugins": [ 6 | "add-module-exports" 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "airbnb", 3 | "env": { 4 | "mocha": true 5 | }, 6 | "rules": { 7 | "semi": [2, "never"], 8 | "no-console": [0], 9 | "no-param-reassign": [0] 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import Base from 'mocha/lib/reporters/base' 2 | 3 | class Emoji extends Base { 4 | 5 | constructor(runner) { 6 | super(runner) 7 | 8 | runner.on('pass', () => { 9 | this.write('😻 ') 10 | }) 11 | 12 | runner.on('pending', () => { 13 | this.write('🙀 ') 14 | }) 15 | 16 | runner.on('fail', (test) => { 17 | test.title += ' 💩 ' 18 | this.write('😿 ') 19 | }) 20 | 21 | runner.on('end', () => { 22 | console.log() 23 | this.epilogue() 24 | }) 25 | } 26 | 27 | write(msg) { 28 | process.stdout.write(msg) 29 | } 30 | 31 | } 32 | 33 | export default Emoji 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/MicheleBertoli/emoji-reporter.svg?branch=master)](https://travis-ci.org/MicheleBertoli/emoji-reporter) 2 | 3 | # emoji-reporter 4 | ❤️ The best [mocha](https://mochajs.org/) reporter ever 5 | 6 | > The best minds of my generation are thinking about how to include emojis in test runner output. That sucks. [@iamdevloper](https://twitter.com/iamdevloper/status/839858241450344448) 7 | 8 | ## Install 9 | 10 | ```bash 11 | npm install emoji-reporter --save-dev 12 | ``` 13 | 14 | ## Usage 15 | 16 | ```bash 17 | mocha --reporter=emoji-reporter 18 | ``` 19 | 20 | ## Preview 21 | 22 | ![Preview](images/screenshot.png) 23 | 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Michele Bertoli 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "emoji-reporter", 3 | "version": "0.3.0", 4 | "description": "❤️ The best mocha reporter ever", 5 | "main": "dist/index.js", 6 | "files": [ 7 | "dist" 8 | ], 9 | "scripts": { 10 | "build": "babel ./src --out-dir ./dist", 11 | "prepublish": "npm run build", 12 | "test": "mocha --compilers js:babel-register", 13 | "test:emoji": "npm run build && npm test -- --reporter dist/index.js" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "url": "git+https://github.com/MicheleBertoli/emoji-reporter.git" 18 | }, 19 | "keywords": [ 20 | "mocha", 21 | "mochajs", 22 | "emoji" 23 | ], 24 | "author": "Michele Bertoli", 25 | "license": "MIT", 26 | "bugs": { 27 | "url": "https://github.com/MicheleBertoli/emoji-reporter/issues" 28 | }, 29 | "homepage": "https://github.com/MicheleBertoli/emoji-reporter#readme", 30 | "devDependencies": { 31 | "babel-cli": "^6.10.1", 32 | "babel-plugin-add-module-exports": "^0.2.1", 33 | "babel-preset-es2015": "^6.9.0", 34 | "babel-register": "^6.9.0", 35 | "eslint": "^2.12.0", 36 | "eslint-config-airbnb": "^9.0.1", 37 | "eslint-plugin-import": "^1.8.1", 38 | "eslint-plugin-jsx-a11y": "^1.4.2", 39 | "eslint-plugin-react": "^5.1.1", 40 | "mocha": "^2.5.3", 41 | "sinon": "^1.17.4" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /test/index.js: -------------------------------------------------------------------------------- 1 | import assert from 'assert' 2 | import sinon from 'sinon' 3 | import { EventEmitter } from 'events' 4 | 5 | import Emoji from '../src/index' 6 | 7 | describe('test', () => { 8 | class Runner extends EventEmitter {} 9 | const noop = () => {} 10 | let runner 11 | let emoji 12 | 13 | beforeEach(() => { 14 | runner = new Runner() 15 | emoji = new Emoji(runner) 16 | 17 | emoji.write = sinon.spy() 18 | emoji.epilogue = sinon.spy() 19 | }) 20 | 21 | it('works on pass', () => { 22 | runner.emit('pass', { slow: noop }) 23 | 24 | assert(emoji.write.calledWithExactly('😻 ')) 25 | }) 26 | 27 | it('works on pending', () => { 28 | runner.emit('pending') 29 | 30 | assert(emoji.write.calledWithExactly('🙀 ')) 31 | }) 32 | 33 | it('works on fail', () => { 34 | runner.emit('fail', {}) 35 | 36 | assert(emoji.write.calledWithExactly('😿 ')) 37 | }) 38 | 39 | it('works on end', () => { 40 | const log = console.log 41 | console.log = sinon.spy() 42 | runner.emit('end') 43 | 44 | assert(console.log.called) 45 | assert(emoji.epilogue.called) 46 | 47 | console.log = log 48 | }) 49 | 50 | it('appends shit to failures', () => { 51 | const test = { title: 'foo' } 52 | runner.emit('fail', test) 53 | 54 | assert.equal(test.title, 'foo 💩 ') 55 | }) 56 | }) 57 | --------------------------------------------------------------------------------