1.3.4 • Published 3 years ago

testaged-coverage v1.3.4

Weekly downloads
1
License
MIT
Repository
github
Last release
3 years ago

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.

1.3.4

3 years ago

1.3.3

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.2.0

4 years ago

1.3.0

4 years ago

1.1.6

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.5

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago