Socket
Socket
Sign inDemoInstall

test-exclude

Package Overview
Dependencies
48
Maintainers
3
Versions
36
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    test-exclude

test for inclusion or exclusion of paths using pkg-conf and globs


Version published
Weekly downloads
23M
decreased by-9.06%
Maintainers
3
Install size
590 kB
Created
Weekly downloads
 

Package description

What is test-exclude?

The test-exclude npm package is used to filter out files that should not be included in test coverage calculations. It allows developers to specify patterns for files to be excluded from coverage reports, typically when using a coverage tool like Istanbul.

What are test-exclude's main functionalities?

Exclude files from coverage

This feature allows developers to define patterns for files that should be excluded from test coverage. The code sample shows an example configuration where files in the node_modules and test directories, as well as files ending with .spec.js, are excluded.

{"exclude": ["**/node_modules/**", "test/**", "**/*.spec.js"]}

Include files in coverage

In contrast to excluding files, this feature allows developers to specify which files should be included in the coverage report. The code sample demonstrates how to include all JavaScript files in the src directory.

{"include": ["src/**/*.js"]}

Use with coverage tools

This feature integrates with coverage tools to determine if a file should be instrumented for coverage. The code sample shows how to use test-exclude to check if a file, in this case './src/index.js', should be included in the coverage report.

const testExclude = require('test-exclude');
const exclude = testExclude({
  exclude: ['**/node_modules/**', 'test/**']
});
console.log(exclude.shouldInstrument('./src/index.js')); // true or false

Other packages similar to test-exclude

Changelog

Source

5.2.0 (2019-03-12)

Features

  • Add TestExclude.globSync to find all files (#309) (2d7ea72)
  • Support turning of node_modules default exclude via flag (#213) (9b4b34c)

Readme

Source

test-exclude

The file include/exclude logic used by nyc.

Build Status Coverage Status Standard Version Greenkeeper badge

Usage

const exclude = require('test-exclude')
if (exclude().shouldInstrument('./foo.js')) {
  // let's instrument this file for test coverage!
}

you can load configuration from a key in package.json:

package.json

{
  "name": "awesome-module",
  "test": {
    "include": ["**/index.js"]
  }
}

app.js

const exclude = require('test-exclude')
if (exclude({configKey: 'test'}).shouldInstrument('./index.js')) {
  // let's instrument this file for test coverage!
}

Including node_modules folder

by default the node_modules folder is added to all groups of exclude rules. In the rare case that you wish to instrument files stored in node_modules, a negative glob can be used:

const exclude = require('test-exclude')
const e = exclude({
  exclude: ['!**/node_modules/**']
})

License

ISC

Keywords

FAQs

Last updated on 12 Mar 2019

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