Socket
Socket
Sign inDemoInstall

testaged-coverage

Package Overview
Dependencies
1
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

testaged-coverage

Utility script to run tests and verify coverage threshold for stages files


Version published
Maintainers
1
Weekly downloads
244
decreased by-64.84%

Weekly downloads

Readme

Source

testaged-coverage · Node.js CI · Node.js Package

Use this library to execute tests on your git staged files and verify they comply with the test coverage threshold.

You can install this dependency globally now (starting 1.3.3)

yarn add global testaged-coverage or

npm install testaged-coverage -g.

Before the tests are run, make sure you have set a Jest "coverageThreshold". You can learn how to configure it here.

// package.json
{
  ...
  "jest": {
    "coverageThreshold": {
      "global": {
        "branches": 80,
        "functions": 80,
        "lines": 80,
        "statements": 80
      }
    }
  }
}

How to use it

You need to stage your files first with git add.

In a pre-commit hook

You will need to have husky installed. In your package.json, add the script to run as a pre-commit hook.

// package.json
{
  "husky": {
    "hooks": {
      "pre-commit": "testaged-coverage && <you can include other scripts here (e.g. lint-staged)>"
    }
  },
}

Directly in command line

Just execute testaged-coverage

Starting 1.3.0 you can add a --basedir array of folders where to look for tests

testaged-coverage --basedir="src scripts folder1 folder2"

By default --basedir is folder src

Troubleshooting

This library assumes you have a script setup for tests in your package.json.

// package.json
{
  "scripts": {
    "test": "jest"
  },
}

If you are using versions 1.3.3 or lower, when running testaged-coverage, you will need to add the environment variable CI=true to your test script in your package.json in order to prevent the script from running in watch mode. This will no longer be necessary from versions 1.3.4 and on.

Keywords

FAQs

Last updated on 24 Mar 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc