GithubHelp home page GithubHelp logo

tim-pala / jest-badges-readme Goto Github PK

View Code? Open in Web Editor NEW

This project forked from olavoparno/jest-badges-readme

0.0 0.0 0.0 291 KB

Creates a group of coverage badges from Jest into your README

License: MIT License

TypeScript 77.72% JavaScript 22.28%

jest-badges-readme's Introduction

Jest Badges Readme

CodeClimate DevDeps GitHub license npm version PRs Welcome BuiltBy ForTheBadge

Creates Jest Coverage badges for your README.md file

Statements Branches Functions Lines Build Status
Statements Branches Functions Lines BuildStatus

TL;DR

  • To be short, all it does is: Creates your README.md dynamically with your Jest Coverage Badges based on your README-template.md file

Installation

  • Global Installation

      npm i -g @olavoparno/jest-badges-readme
  • Local Installation

      npm i @olavoparno/jest-badges-readme --save-dev

Configuration and requirements

  1. Have Jest installed and with its Coverage Reporting configuration as below
  • It may be set inside your Jest config within package.json or inside your jest config file i.e. jest.config.js or jestconfig.json

      "coverageReporters": [
        "json-summary",
        "text",
        "lcov"
      ]
  1. Have a README-template.md file created with the following template (please do feel free to change its presentation structure, e.g. in a table or not)
| Statements | Branches | Functions | Lines |
| -----------|----------|-----------|-------|
| ![Statements](#statements# "Make me better!") | ![Branches](#branches# "Make me better!") | ![Functions](#functions# "Make me better!") | ![Lines](#lines# "Make me better!") |
  1. Call if from your terminal or from your NPM/YARN Scripts
  • For locally installed library

      "make-badges": "node_modules/.bin/jest-badges-readme"
  • For globally installed library

      "make-badges": "npm run jest-badges-readme"
  • You may also provide a different coverage folder path passed as arguments

      "make-badges": "npm run jest-badges-readme --coverageDir='./my-custom-coverage-folder'"
  • And finally via the very terminal

      jest-badges-readme --coverageDir='./my-custom-coverage-folder'

Short summary onto what Jest and Jest Badges Readme covers for us

  • % Stmts (which states for Statements)
  • % Branch (pretty self explanatory)
  • % Functions (won't repeat myself)
  • % Lines (last but not least)

This library will create badges URLs for these former 4 items into your README-template.md if you followed the previous steps

  • Open up your README-template.md and add 4 markers inside it for each Jest coverage item respectively. These markers must be as follows:

    1. '#statements#'
    2. '#branches#'
    3. '#functions#'
    4. '#lines#'

If you feel you might need a local building badge indicator, add these NPM scripts in order to manage your local building badge as well

  "prebuild": "echo nok > .buildstatus",
  "postbuild": "echo ok > .buildstatus"
  • Add one more marker like the example below. This is going to create a file called .buildstatus in your project's root telling this library if your build is either successful or a failure
    1. '#buildstatus#'

Example of README-template.md with building status too

| Statements | Branches | Functions | Lines | Build Status |
| -----------|----------|-----------|-------| ------------ |
| ![Statements](#statements# "Make me better!") | ![Branches](#branches# "Make me better!") | ![Functions](#functions# "Make me better!") | ![Lines](#lines# "Make me better!") | ![BuildStatus](#buildstatus# "Building Status") |

Using as a part of your githooks

  • If you want to have this run on the precommit hook and update the commit in place, just install husky and add the precommit script to your package.json
  1. Install Husky
  npm install --save-dev husky 
  1. Add your precommit script
  "husky": {
    "hooks": {
      "pre-commit": "jest && node_modules/.bin/jest-badges-readme && git add 'README.md'"
    }
  }
  1. Git Commit and Push. Just use your workflow as usual. If your tests fail, no commit. If they pass, update the README.md and add the file to the commit. Nice!

Contributing

The purpose of this library is to motivate developers to constantly write a solid documentation and testing. A complete and nice looking documentation is key to a successful development and code maintainability. Please feel free to open any issues you might come up with and to submit your own PRs. There is not a contributing guide yet

Contributors

Thanks goes to these wonderful people (emoji key):

Olavo Parno
Olavo Parno

๐Ÿค” ๐Ÿ’ป โš ๏ธ
nothingismagick
nothingismagick

๐Ÿค” ๐Ÿ› ๐Ÿ–‹
Dave Fisher
Dave Fisher

๐Ÿ›

This project follows the all-contributors specification. Contributions of any kind welcome!

License

Jest Badges Readme is MIT licensed.

jest-badges-readme's People

Contributors

allcontributors[bot] avatar nothingismagick avatar olavoparno avatar olavoparno-geru 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.