budibase/packages/common/node_modules/test-exclude/README.md

57 lines
1.5 KiB
Markdown
Raw Normal View History

2020-04-07 16:12:08 +02:00
# test-exclude
The file include/exclude logic used by [nyc](https://github.com/istanbuljs/nyc).
2020-04-07 16:12:08 +02:00
[![Build Status](https://travis-ci.org/istanbuljs/test-exclude.svg)](https://travis-ci.org/istanbuljs/test-exclude)
[![Coverage Status](https://coveralls.io/repos/github/istanbuljs/test-exclude/badge.svg?branch=master)](https://coveralls.io/github/istanbuljs/test-exclude?branch=master)
[![Standard Version](https://img.shields.io/badge/release-standard%20version-brightgreen.svg)](https://github.com/conventional-changelog/standard-version)
[![Greenkeeper badge](https://badges.greenkeeper.io/istanbuljs/test-exclude.svg)](https://greenkeeper.io/)
## Usage
```js
const exclude = require('test-exclude');
2020-04-07 16:12:08 +02:00
if (exclude().shouldInstrument('./foo.js')) {
// let's instrument this file for test coverage!
}
```
_you can load configuration from a key in package.json:_
2020-04-07 16:12:08 +02:00
_package.json_
2020-04-07 16:12:08 +02:00
```json
{
"name": "awesome-module",
"test": {
"include": ["**/index.js"]
}
}
```
2020-04-07 16:12:08 +02:00
_app.js_
2020-04-07 16:12:08 +02:00
```js
const exclude = require('test-exclude');
if (exclude({ configKey: 'test' }).shouldInstrument('./index.js')) {
// let's instrument this file for test coverage!
}
2020-04-07 16:12:08 +02:00
```
## Including node_modules folder
2020-04-07 16:12:08 +02:00
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:
2020-04-07 16:12:08 +02:00
```js
const exclude = require('test-exclude');
const e = exclude({
exclude: ['!**/node_modules/**']
});
```
2020-04-07 16:12:08 +02:00
## License
2020-04-07 16:12:08 +02:00
ISC