JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 33
  • Score
    100M100P100Q68045F
  • License MIT

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

Package Exports

  • testaged-coverage

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (testaged-coverage) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

testaged-coverage · Node.js CI

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

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

{
  ...
  "jest": {
    "coverageThreshold": {
      "global": {
        "branches": 80,
        "functions": 80,
        "lines": 80,
        "statements": -10
      }
    }
  }
}

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": "node ./node_modules/testaged-coverage && <you can include other scripts here (e.g. lint-staged)>"
    }
  },
}

Directly in command line

Just execute node ./node_modules/testaged-coverage

Troubleshooting

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

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

If you are using react-scripts test, you need to add the environment variable CI=true to prevent the script from running in watch mode.