tunnckoCore/dush-tap-report

View on GitHub
README.md

Summary

Maintainability
Test Coverage
# dush-tap-report [![NPM version](https://img.shields.io/npm/v/dush-tap-report.svg?style=flat)](https://www.npmjs.com/package/dush-tap-report) [![mit license][license-img]][license-url] [![NPM monthly downloads](https://img.shields.io/npm/dm/dush-tap-report.svg?style=flat)](https://npmjs.org/package/dush-tap-report) [![npm total downloads][downloads-img]][downloads-url]

> A simple TAP report producer based on event system. A plugin for `dush` event emitter or anything based on it

[![code climate][codeclimate-img]][codeclimate-url] 
[![code style][standard-img]][standard-url] 
[![linux build][travis-img]][travis-url] 
[![windows build][appveyor-img]][appveyor-url] 
[![code coverage][coverage-img]][coverage-url] 
[![dependency status][david-img]][david-url]
[![paypal donate][paypalme-img]][paypalme-url] 

You might also be interested in [dush][] - an event emitter system, extensible through plugins.
Or [minibase][], a tiny framework based on `dush` for building robust and complex applications.

## Table of Contents
- [Install](#install)
- [Usage](#usage)
- [API](#api)
  * [tapReport](#tapreport)
- [Related](#related)
- [Contributing](#contributing)
- [Building docs](#building-docs)
- [Running tests](#running-tests)
- [Author](#author)
- [License](#license)

_(TOC generated by [verb](https://github.com/verbose/verb) using [markdown-toc](https://github.com/jonschlinkert/markdown-toc))_

## Install
Install with [npm](https://www.npmjs.com/)

```
$ npm install dush-tap-report --save
```

or install using [yarn](https://yarnpkg.com)

```
$ yarn add dush-tap-report
```

## Usage
> For more use-cases see the [tests](test.js)

```js
const dushTapReport = require('dush-tap-report')
```

## API

### [tapReport](index.js#L93)
> A simple TAP report producing plugin for [dush][] or anything based on it. It returns a function that can be passed to dush's `.use` method. This plugin will also work for [minibase][] and [base][] mini frameworks for building robust apps.

**Params**

* `options` **{Object}**: optional options, merged with `app.options`, passed to [stacktrace-metadata][] and [find-callsite][]    
* `options.writeLine` **{Function}**: a logger function called on each line, default `console.log`    
* `options.cleanStack` **{Boolean}**: if `false` won't clean stack trace from node internals, [clean-stacktrace][]    
* `options.shortStack` **{Boolean}**: if `false` full stack traces, otherwise they are just four    
* `options.showStack` **{Boolean}**: if `false` the error.stack will be empty string    
* `options.relativePaths` **{Boolean}**: if `false` paths in stack traces will be absolute, [clean-stacktrace-relative-paths][]    
* `options.mapper` **{Function}**: called on each line of the stack with `(line, index)` signature    
* `options.cwd` **{String}**: current working directory, default `process.cwd()`    
* `returns` **{Function}**: a plugin function that should be passed to `.use` method of [minibase][], [base][] or [dush][]  

**Example**

```js
const reporter = require('dush-tap-report')
const dush = require('dush')

const app = dush()

// provide a fake stats object
// so `finish` to work correctly
app.use(reporter({
  stats: {
    count: 3,
    pass: 2,
    fail: 1
  }
}))

const item = {
  index: 1,
  title: 'some passing test'
}
const failing = {
  index: 2,
  title: 'failing test, sorry',
  reason: new Error('some sad error here')
}
const item2 = {
  index: 3,
  title: 'awesome test is okey'
}

app.emit('start', app)
// => 'TAP version 13'

app.emit('pass', app, item)
// =>
// # :) some passing test
// ok 1 - some passing test

app.emit('fail', app, failing)
// =>
// # :( failing test, sorry
// not ok 2 - failing test, sorry

app.emit('pass', app, item2)
// =>
// # :) awesome test is okey
// ok 3 - awesome test is okey

app.emit('finish', app)
// =>
// 1..3
// # tests 3
// # pass  2
// # fail  1
```

## Related
- [always-done](https://www.npmjs.com/package/always-done): Handle completion and errors with elegance! Support for streams, callbacks, promises, child processes, async/await and sync functions. A drop-in replacement… [more](https://github.com/hybridables/always-done#readme) | [homepage](https://github.com/hybridables/always-done#readme "Handle completion and errors with elegance! Support for streams, callbacks, promises, child processes, async/await and sync functions. A drop-in replacement for [async-done][] - pass 100% of its tests plus more")
- [clean-stacktrace](https://www.npmjs.com/package/clean-stacktrace): Clean up error stack traces from node internals | [homepage](https://github.com/tunnckocore/clean-stacktrace#readme "Clean up error stack traces from node internals")
- [minibase-create-plugin](https://www.npmjs.com/package/minibase-create-plugin): Utility for [minibase][] and [base][] that helps you create plugins | [homepage](https://github.com/node-minibase/minibase-create-plugin#readme "Utility for [minibase][] and [base][] that helps you create plugins")
- [minibase-is-registered](https://www.npmjs.com/package/minibase-is-registered): Plugin for [minibase][] and [base][], that adds `isRegistered` method to your application to detect if plugin is already registered and… [more](https://github.com/node-minibase/minibase-is-registered#readme) | [homepage](https://github.com/node-minibase/minibase-is-registered#readme "Plugin for [minibase][] and [base][], that adds `isRegistered` method to your application to detect if plugin is already registered and returns true or false if named plugin is already registered on the instance.")
- [minibase](https://www.npmjs.com/package/minibase): Minimalist alternative for Base. Build complex APIs with small units called plugins. Works well with most of the already existing… [more](https://github.com/node-minibase/minibase#readme) | [homepage](https://github.com/node-minibase/minibase#readme "Minimalist alternative for Base. Build complex APIs with small units called plugins. Works well with most of the already existing [base][] plugins.")
- [stacktrace-metadata](https://www.npmjs.com/package/stacktrace-metadata): Modify given `err` object to be more useful - adds `at`, `line`, `column`, `place` and `filename` properties and also cleans… [more](https://github.com/tunnckocore/stacktrace-metadata#readme) | [homepage](https://github.com/tunnckocore/stacktrace-metadata#readme "Modify given `err` object to be more useful - adds `at`, `line`, `column`, `place` and `filename` properties and also cleans stack traces.")
- [try-catch-core](https://www.npmjs.com/package/try-catch-core): Low-level package to handle completion and errors of sync or asynchronous functions, using [once][] and [dezalgo][] libs. Useful for and… [more](https://github.com/hybridables/try-catch-core#readme) | [homepage](https://github.com/hybridables/try-catch-core#readme "Low-level package to handle completion and errors of sync or asynchronous functions, using [once][] and [dezalgo][] libs. Useful for and used in higher-level libs such as [always-done][] to handle completion of anything.")

## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/tunnckoCore/dush-tap-report/issues/new).  
Please read the [contributing guidelines](CONTRIBUTING.md) for advice on opening issues, pull requests, and coding standards.  
If you need some help and can spent some cash, feel free to [contact me at CodeMentor.io](https://www.codementor.io/tunnckocore?utm_source=github&utm_medium=button&utm_term=tunnckocore&utm_campaign=github) too.

**In short:** If you want to contribute to that project, please follow these things

1. Please DO NOT edit [README.md](README.md), [CHANGELOG.md](CHANGELOG.md) and [.verb.md](.verb.md) files. See ["Building docs"](#building-docs) section.
2. Ensure anything is okey by installing the dependencies and run the tests. See ["Running tests"](#running-tests) section.
3. Always use `npm run commit` to commit changes instead of `git commit`, because it is interactive and user-friendly. It uses [commitizen][] behind the scenes, which follows Conventional Changelog idealogy.
4. Do NOT bump the version in package.json. For that we use `npm run release`, which is [standard-version][] and follows Conventional Changelog idealogy.

Thanks a lot! :)

## Building docs
Documentation and that readme is generated using [verb-generate-readme][], which is a [verb][] generator, so you need to install both of them and then run `verb` command like that

```
$ npm install verbose/verb#dev verb-generate-readme --global && verb
```

_Please don't edit the README directly. Any changes to the readme must be made in [.verb.md](.verb.md)._

## Running tests
Clone repository and run the following in that cloned directory

```
$ npm install && npm test
```

## Author
**Charlike Mike Reagent**

+ [github/tunnckoCore](https://github.com/tunnckoCore)
+ [twitter/tunnckoCore](https://twitter.com/tunnckoCore)
+ [codementor/tunnckoCore](https://codementor.io/tunnckoCore)

## License
Copyright © 2017, [Charlike Mike Reagent](https://i.am.charlike.online). Released under the [MIT License](LICENSE).

***

_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.3, on March 19, 2017._  
_Project scaffolded using [charlike][] cli._

[always-done]: https://github.com/hybridables/always-done
[async-done]: https://github.com/gulpjs/async-done
[base]: https://github.com/node-base/base
[charlike]: https://github.com/tunnckocore/charlike
[clean-stacktrace-relative-paths]: https://github.com/tunnckocore/clean-stacktrace-relative-paths
[clean-stacktrace]: https://github.com/tunnckocore/clean-stacktrace
[commitizen]: https://github.com/commitizen/cz-cli
[dezalgo]: https://github.com/npm/dezalgo
[dush]: https://github.com/tunnckocore/dush
[find-callsite]: https://github.com/tunnckocore/find-callsite
[minibase]: https://github.com/node-minibase/minibase
[once]: https://github.com/isaacs/once
[stacktrace-metadata]: https://github.com/tunnckocore/stacktrace-metadata
[standard-version]: https://github.com/conventional-changelog/standard-version
[verb-generate-readme]: https://github.com/verbose/verb-generate-readme
[verb]: https://github.com/verbose/verb

[license-url]: https://www.npmjs.com/package/dush-tap-report
[license-img]: https://img.shields.io/npm/l/dush-tap-report.svg

[downloads-url]: https://www.npmjs.com/package/dush-tap-report
[downloads-img]: https://img.shields.io/npm/dt/dush-tap-report.svg

[codeclimate-url]: https://codeclimate.com/github/tunnckoCore/dush-tap-report
[codeclimate-img]: https://img.shields.io/codeclimate/github/tunnckoCore/dush-tap-report.svg

[travis-url]: https://travis-ci.org/tunnckoCore/dush-tap-report
[travis-img]: https://img.shields.io/travis/tunnckoCore/dush-tap-report/master.svg?label=linux

[appveyor-url]: https://ci.appveyor.com/project/tunnckoCore/dush-tap-report
[appveyor-img]: https://img.shields.io/appveyor/ci/tunnckoCore/dush-tap-report/master.svg?label=windows

[coverage-url]: https://codecov.io/gh/tunnckoCore/dush-tap-report
[coverage-img]: https://img.shields.io/codecov/c/github/tunnckoCore/dush-tap-report/master.svg

[david-url]: https://david-dm.org/tunnckoCore/dush-tap-report
[david-img]: https://img.shields.io/david/tunnckoCore/dush-tap-report.svg

[standard-url]: https://github.com/feross/standard
[standard-img]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg

[paypalme-url]: https://www.paypal.me/tunnckoCore
[paypalme-img]: https://img.shields.io/badge/paypal-donate-brightgreen.svg